一.web服务器 解析:Tomcat服务器 一款Web服务器 解析jsp页面 jsp转换成普通页面 打回给浏览器 步骤: 1.建立一个web项目 2.xiugaijsp页面编码方式 uft-8 3.下载Tomcat文件,解压复制到C盘更目录 4.Window-show view-other-Serves-servers点击ok 5.window-preferences-MyEclipse-Severs-Tomcat 将Disable设置为enable-Browse找到Tomcat文件夹 点击Apply-点击ok 6.Tomcat6.x 添加项目 选第一个 7.在浏览器中运行项目 二.程序架构 B/S和C/S
B/S:必须要借助浏览器才可以执行的程序
优点:方便程序的升级,一旦程序的功能需要发生变更的时候,只需要更新服务器端的程序
,客户端的程序也就是浏览器不需要进行任何附加的操作。
C/S:不需要借助浏览器就可以访问的程序
优点:01.交互性好:可以更好的让用户使用快捷键
02.更好的控制硬件。 三.URL和URI URI:Uniform Resource Identifier,统一资源标识符; URL:Uniform Resource Locator,统一资源定位符; URL是唯一能识别Internet上具体的计算机、目录或文件夹位置的命名约定 URN:Uniform Resource Name,统一资源名称。
tomcat:
apache:
Weblogic
Jboss
webspacher
Jetty
IIS (解析.NET 程序)
Nginx高性能
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> 小脚本: <%! boolean findyear(int year){ if((year%4==0&&year0!=0)||year@0==0){ return true; }else{ return false; } } %> <% int count=0; for(int i=2000;i<2014;i++){ if(findyear(i)){ count++; } }%> 从2000-2013年期间,一共有<%=count %>个闰年 </body> </html>项目改名: 1.fn+f2
2.项目右击-最后一项-web-ok-finish
起始页的设置 web.xml
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> 地址名:http://localhost:8080/Day-0100/
jsp
小脚本:存在内存中
<% int num=5; int num2=5%>
表达式:页面上
<%=num%>
<%!
%>
注释:
<%-- --%>
html注释 <%-- jsp注释 --%> java液面,java类有,前段html源代码有
jsp <%-- jsp注释--%>只有当前jsp页面有
java注释 // 不会显示
page 指令
<%@ page language="java" import="java.util.*" pageEncoding="utf-8 conten" contentType="text/html; charset=utf-8% > 格式 一个是页面 一个是浏览器
