1.B / S and C / S
Comparative aB / S and C / S of
B / S structure | B / S structure | |
Software Installation | Browser | The need for specialized client application |
Upgrade and maintenance | Zero client maintenance | The client requires a separate maintenance and upgrades |
Platform-dependent | Relationship with the operating system platform to minimize | The client operating systems are generally limited |
Performance Security | In response speed and security need to spend more design costs | Can give full play to the client processing capabilities, fast response clients |
b. What is B / S Technology
B / S architecture (Browser / server): The program is fully deployed on the server
Works B / S art: B / S architecture uses a request / response interaction mode
2. URL (Uniform Resource Locator Uniform Resource Locator)
URL composition -
3. Tomcat Server Introduction
Tomcat server: Apache Jakarta open source projects, JSP / Servlet container
Tomcat server's directory structure
table of Contents | Explanation |
/bin | Used to start and stop the Tomcat script files are stored under a variety of platforms |
/conf | Tomcat server storing various profiles |
/lib | Tomcat server storage required for a variety of JAR file |
/logs | Tomcat log file storage |
/temp | Tomcat runtime for temporary files |
/webapps | When you publish a Web application, Web files will be applied by default stored in this directory |
/work | Tomcat JSP Servlet generated by the discharge at this directory |
Tomcat server applications:
a. Unzip version of Tomcat configuration
Adding system variables, the name for the installation directory CATALINA_HOME, the value of Tomcat
Because Tomcat runs dependent on JRE, ensure that the JRE is installed and configured JRE_HOME environment variable.
Or configuration environment variable JAVA_HOME for JDK installed
b. Start and stop the Tomcat server
c.Tomcat service starts detection
IE address bar enter http: // localhost: port number
Tomcat start page into a successful interface
Tomcat port configuration: Modify Tomcat port number through the configuration file server.xml
4. Web project
The directory structure a. Web project
table of Contents | Explanation |
/ | Web application root directory of all the files in the directory can be accessed by the client (JSP, HTML, etc.) |
/ WEB-INF | Storage applications using a variety of resources, the directory and its subdirectories are not accessible to the client |
/WEB-INF/classes | Store all class files Web project |
/WEB-INF/classes | JAR file storage Web application to use |
b. Create, deploy, and publish project steps
Replication creates a page to the next application directory - code written Web applications - Create an application directory in the webapps directory
- Start the Tomcat service and access
c. Configure access page
web.xml modify configuration files accessed by the start page
d. Use an integrated development tool to create Web project
- Create a Web project: File -> New -> Web Project
- Naming and adjust the settings for the project
- View project directory structure
e. Common Errors
Tomcat does not start
Not to deploy Web applications
URL input errors
The directory can not be referenced: META-INF, the contents of WEB-INF folder can not be released - the index.html file folder drag WebRoot
5. JSP
a.jsp Profile
---- JSP (Java Server Pages) embedded Java script code in HTML
<%@ page language="java" import="java.util.*,java.text.*"
contentType= "text/html; charset=utf-8" %>
<html>
<head>
<title>输出当前日期</title>
</head>
<body>
你好,今天是
<% SimpleDateFormat formater =
new SimpleDateFormat("yyyy年 MM月dd日");
String strCurrentTime = formater.format(new Date()); %>
<%=strCurrentTime %>
</body>
</html>
b. JSP page of instructions
---- attributes defined by a plurality of internal properties of the entire page
Syntax: < % @ Page Attribute 1 = "attribute value" Attribute 2 = "1 attribute value, the attribute value 2" ... n-attribute = "attribute value n"%>
Common properties
Attributes | description | Defaults |
language | Specifies the scripting language used in the JSP page | java |
import | Scripting language used to refer to the class files through the property | no |
contentType | It is used to specify the encoding used by JSP pages | text/html, ISO-8859-1 |
c.JSP in small script and expression
<Logic code%%>
<%=变量名%>:相当于输出语句
d. JSP中的声明(定义方法)
语法:<%! Java代码%>
e.JSP中的注释
HTML的注释 : <!-- html注释-->
JSP注释 : <%-- JSP注释--%>
在JSP脚本中注释 :
<% //单行注释 %>
<% /*多行注释 */ %>
f.JSP页面元素小结
g.JSP 执行过程
Web容器处理JSP文件请求需要经过3个阶段:
1.翻译阶段--2.编译阶段--3.执行阶段
第一次请求之后,Web容器可以重用已经编译好的字节码文件
(如果对JSP文件进行了修改,Web容器会重新对JSP文件进行翻译和编译)