China Naming Network - Ziwei Dou Shu - [rookie problem] Tomcat+JSP configuration

[rookie problem] Tomcat+JSP configuration

After installing Tomcat, on my computer-> Attribute-> Advanced-> Environmental variables->; Add the following environment variables to the system variables (assuming your tomcat is installed in c:\tomcat):

CATALINA_HOME:c:\tomcat

CATALINA_BASE:c:\tomcat

TOMCAT_HOME: C:\Tomcat

Then modify the classpath in the environment variable and append servlet.jar under common\lib in the tomat installation directory to the classpath. The modified classpath is as follows:

Classpath =. ; % JAVA _ HOME % \ lib \ dt . jar; % JAVA _ HOME % \ lib \ tools.jar% CATALINA _ HOME % \ common \ lib \ servlet-API . jar;

1. Go to the webapps directory of Tomcat's installation directory, and you can see Tomcat's own root directory, examples, tomcat-docs and other directories.

2. Create a new directory under the webapps directory and name it myapp;;

3. Create a new directory WEB-INF under 3.myapp, and note that the directory name is case-sensitive;

4. Create a new file web.xml under 4. WEB-INF, which contains the following contents:

& lt? Xml version =" 1.0 "code ="ISO-8859- 1"? & gt

& lt! DOCTYPE network application

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN "

"/dtd/we B- app _ 2 _ 3 . dtd " & gt;

& ltwe B- app & gt;

& lt/display-name & gt; my Web application & lt/display-name >

& lt description & gt

Test application.

& lt/description & gt;

& lt/we B- app & gt;

5. Create a new jsp page for testing under myapp. The file name is index.jsp, and the contents of the file are as follows:

& lthtml & gt

& ltbody & gt

& lt center & gt

Now the time is:<% = newjava.util.date ()% >

& lt/center & gt;

& lt/body & gt;

& lt/html & gt;

6. restart Tomcat

7. Open a browser and enter http://localhost: 8080/myapp/index.jsp. If you see the current time, it means success.

According to the above configuration, you are sure to succeed, so am I. I wish you success! !