WEB Project
1. What is the Web it?
Web pages mean, all the information we see in the browser is called WEB resources.
WEB resources are divided into static and dynamic resource WEB WEB resources.
Static WEB Resources: code unchanged, the content displayed on the same. eg: HTML, CSS, JS, images, videos and so on.
Dynamic WEB Resources: content displayed by the program control. eg: JSP / Servlet, ASP, PHP, Ruby, Python and so on.
2, two software architectures Comparative B / S and C / S
B / S browser / server, interacting with the server through a browser, no need to install other applications. Such as Taobao, Jingdong
The advantage of this architecture is: simple to maintain and upgrade, do not install the program, reducing the cost
The disadvantage is that: page effect controlled by the server, poor information security control, a heavier burden on the server, AJAX can improve the user experience
C / S is a client / server, require users to install the application on a computer. As Landlords and so on.
The advantage of this architecture are: effective, user experience is good, safe information, the server less pressure, part of the calculation on the client side
The disadvantage is that: For users accounted for disk space, maintenance problems, the need to constantly upgrade the client, install rely on other software.
3, WEB communication mode request - response
1, the browser needs to view a resource server, it sends a request to the server;
2, the server receives the browser request, processing the request;
3, the server process is completed, the results will response back to the browser
4, the browser based on the response, showing resource information
Note: You must first request the browser, will have a response to the request and the server's response must appear in pairs
4, the position of the request path URL, Internet resources
Format: protocol: // domain : port number / resource position ? Parameter = value
Protocol, http, https, ftp, etc. must be written []
Domain name, domain name or IP address, can access resources [WEB] have to write
Port number, the program must use the port number, so that we can access another computer. Usually port 8080.
Resource location, is used to describe a position on the WEB server resources again.
= Parameter value, the browser and server interaction data transferred
5, the common WEB server
1, Tomcat: Apache organization provides a free, small server software. Supports Servlet and JSP specifications. (Use to)
2, WebLogic: Bea company charges a large-scale server software, after the Oracle acquisition.
All the computing power to support EE specification of a strong, high stability
3, WebSphere: IBM's charges of a very large server software, supports all norms of EE.
Database using DB2, IBM series machines use for banking, finance, securities, its computing power no one around, strong stability
Community Edition: Geronimo
4, JBoss: it is based on open source J2EE application server.
JBoss is a management EJB container and server, JBoss core services do not include support servlet / JSP the WEB container, Tomcat or Jetty generally binding uses.
Tomcat server
1, Tomcat server's Apache is a free, open-source Web application server, are lightweight application server, is widely used in many occasions are not small and medium systems and concurrent user access is the first choice of program development and debugging JSP . Supports Servlet and JSP specifications, and the latest Servlet and JSP specifications can always be reflected in Tomcat.
2, Tomcat installation
Step One: Download
Download: http://tomcat.apache.org/whichversion.html
Select the corresponding system version can.
Step two: unzip the downloaded file
Unzip the file after the move to a path of no Chinese and spaces under
Note: The directory hierarchy not too deep, and the path not to have Chinese and special symbols
3, tomcat directory structure
bin directory: script directory (storage startup, shut down the server commands)
shutdown the server closes the open server startup
Conf directory: directory to store configuration files
Lib: storage jar package to be used
Logs: store log files
Temp: temporary files
Work: After compiling jsp files generated .java file and .class file storage directory
4, the server's startup and shutdown
Double-click startup.bat, use a browser to access http: // localhost: 8080 /, if you see
On behalf of a successful visit
Close: shutdown.dat normal close, or close the command window belonging abnormal shutdown ctrl + c
5. Frequently Asked Questions
Server flash back problem, only JAVA_HOME configured correctly before they can start the server properly, please Baidu own configuration JAVA_HOME
Conflict port number: java.net.BindException: Address already in use: JVM_Bind
Disposition: 1, close the program is using this port
cmd> netstat -ano to see which programs are using which ports, find the port occupied by the program
taskkill / pid process name / f / f is forced to kill
2. Replace the port number in the server.xml file
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
6, WEB project directory structure
project name
| ----- static resources .HTML, CSS, JS, pictures, video .....
| ----- WEB-INF
| ---- web.xml current core configuration WEB projects, Servlet2.5 must have, 3.0 can be omitted (using annotations).
| ---- jar of third-party storage location lib WEB currently needed for the project.
|----classes Java源码编译后生成class文件存放的位置。Serlvet,service,dao,utils.相当于src目录
只要WEB项目符合规范,放置在webapps目录中,服务器就会将其顺利发布网络
注:WEB-INF是受保护目录,从浏览器不能直接访问,只有通过请求转发
7、如何发布项目到Tomcat中
方式一:
拷贝项目文件夹到tomcat的webapps目录中
方式二: 不建议使用,配置错误可能导致服务器无法启动
修改tomcat的server.xml
<Host> <Context path="/访问路径" docBase="D:/aaa"></Context></Host>
path 访问的虚拟路径
docBase 项目所在的真实路径
方式三:
在tomcat的 config/catalina/localhost/目录下创建 ***.xml
在 xml文件中:
<Context docBase=E:\ccc"></Context>
docBase 项目所在的真实路径 path不用写
虚拟路径就是这个xml文件的文件名
xml文件名可以用来分级 例如:xyz.xml 路径就是 xyz/
xyz#aaa.xml 路径就是 xyz/aaa/ #--------用来做分级
8、eclipse中使用tomcat
window-->preferences-->搜索server-->runtime Encironme-->add-->选择tomcat对应版本-->next-->Browse选择tomcat安装路径-->finish
这时,eclipse中的
有了这个服务器,注意:千万不要启动服务器
(如果没有这个窗口,可以在window-->show view-->servers调出)
双击Tomcat 会弹出一个配置页面
选择第二个,同时修改下方的Deploy path如图所示,修改完毕后ctrl+s保存关闭即可
右击Tomcat-->Add remove可以添加WEB项目,右击启动即可