==Tomcat Install and Configure (http://www.coreservlets.com/Apache-Tomcat-Tutorial/)
-实现了JAVAEE标准的最小WEB服务器, Apache开发。
0. No separate Apache installation needed
1. Installed folders
C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0
bin/ : all tomcat binaries, including exe to start tomcat server
lib/ : all java jar files used to compile and run java
conf/ : configure, setting port, map between web dir and local dir
log/:
webapp/: all web project files, could be added by user. This is default web file location
work/ : all temporary files including .java and .class, clean it if needed
2. Set JAVA_HOME pointing to JDK top dir. Tomcat use JD
3. Start tomcat:
C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7.exe
4. Check the web: http://localhost:8080/
5. Further configuration
5.1 (optional) webserver port. by server.xml
<Connector port="8080" protocol="HTTP/1.1" ==> port
5.2 (optional but recommended) set map between web dir and local dir (virtual dir) ,
a. create a local dir which has the following structure
<application_root>/WEB-INF/web.xml ( copy from webapps\ROOT\WEB-INF\web.xml)
b. configure map on server.xml: Adding the following right before </Host>
<Context path="/demo" docBase="E:\linfa\work\webdemo"/>
Note: path is the path in the web browser, docBase is the path of files
5.3 (optional but recommended on development) enable list files on dir. web.xml
Fix: modify conf/web.xml: change "false" to "true"
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
restart the server, should have "Directory Listing For /"
5.4 (optional but recommended on development) enable apps management on tomcat-user.xml: Adding the following
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="admin,manager,tomcat"/>
==The first jsp program
1. creating E:\linfa\work\webdemo\hello.jsp . jst file is adding java code into html file
<html>
<head>
<title> Hello Jsp World!!!</title>
</head>
<body>
<%
out.println("Hello World with Newline<br>");
out.println("Hello World without Newline");
%>
</body>
</html>
==Under the hood
1. The first time *.jsp->*.java->*.class->run *.class
2. The second time *.jsp -> run *.class
3. the *.java and *.class should be in tomcat work dir ( I could not find it?)
没有评论:
发表评论