Source: csdn Author: cl41
Configure Eclpise+tomcat and implement JSP writing and deployment
1. Download J2SDK download http://java.sun.com/j2se/1.4.2/download.html
The download version is j2sdk-1_4_2_08
ECLIPSE download http://www.eclipse.org/downloads/index.php
The download version is eclipse-SDK-3.0.2-win32
ECLIPSE plug-in download
TOMCAT download http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
The download version is jakarta-tomcat-5.0.282
. Installation 1. Install j2sdk first
My installation path is: D:Program FilesJavaj2sdk
2. Then install eclipse
Eclipse is green software and does not need to be installed. Just decompress the downloaded eclipse compressed package. My installation path is: D:Program FilesJavaeclipse
3. Install tomcat
What is downloaded is an installation file. Just follow the installation prompts. My installation path is: D:Program FilesJavaTomcat
4. Install the eclipse plug-in Chinese package and directly compress the package NLpack-eclipse-SDK-3.0.x -Just unzip the contents of the features and plugins folders in win32 to a folder with the same name in the eclipse folder.
The Tomcat plug-in decompresses the compressed package tomcatPluginV3, and decompresses the contents of the plugins folder to a folder with the same name in the eclipse folder.
three. Environment configuration 1. System environment variable configuration, right-click "My Computer"->Advanced->Environment Variables,
Set the JAVA_HOME variable to point to the installation directory "D:Program FilesJavaj2sdk";
The TOMCAT_HOME variable points to the directory where it is installed "D:Program FilesJavaTomcat";
The PATH variable contains "%JAVA_HOME%bin;";
The CLASSPATH variable contains "%JAVA_HOME%libtools.jar;";
2. The configuration of the java running environment in eclipse is in the eclipse main window, "Window"->Preferences->java->Installed JRE, select us Already installed j2sdk
3. Configure the Sysdeo Tomcat plug-in in the eclipse main window, "Window"->Preferences->tomcat, select version 5.x for tomcat version (the version we installed), and fill in the path where we installed tomcat at tomcat home. , here is D:Program FilesJavaTomcat.
Switch to the Advanced option and fill in the path where we installed tomcat at tomcat base. This is D:Program FilesJavaTomcat.
Switch to the JVM Setting option and make sure jre is the j2sdk version you have installed. We choose j2sdk here.
Switch to Tomcat Manger App and add a user to the management interface.
Finally press the Apply button and then OK.
To check whether the configuration is successful, just press the tomcat run button in the eclipse main window, and then enter http://localhost:8080 in the address bar of the browser. If the tomcat page appears, it proves that the configuration is successful.
Four. Writing a program 1. Create a Tomcat project. Right-click the blank space in the "Package Explorer" window, click New -> Tomcat Project, fill in the project name in the project name, here I fill in tomcat_test, and click "Finish".
2. Create a JSP page in the package explorer, right-click "tomcat_test", click New -> File, fill in HelloWorld.jsp in the file name (the extension is required), and enter the following code in the text editing window:
<html>
<head>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Then save.
five. Deploying the JSP page I use a relatively simple method for deployment here: first, copy the tomcat_test directory placed in the workpalce directory of eclipse to the webapps directory under the tomcat directory, and then text-edit the server.xml in the conf directory. Add the following host element before </engin>:
<Host name="*.*.*.*" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
</Host>
Then save, then start tomcat, so that as long as you are browsing Enter http://*.*.*.*:8080/tomcat_test/HelloWorld.jsp in the browser window and the browser will display "Hello World". This means that your jsp page is successfully deployed and published, and others can visit you online. page.
(PS: *.*.*.* refers to the IP address of the host where the tomcat server is installed)
six. A few explanations (1) Choose j2sdk instead of jre because j2sdk not only has the running environment of java but also has the classes required by java programs, while jre only has the running environment.
(2) Since the software itself is upgraded frequently, it is often necessary to reset the environment variables used or reconfigure it. For example, upgrading the JDK version from 1.3 to 1.4, that is, the JDK directory name may need to be changed from "j2sdk1.3" to "j2sdk1.4" ", if this is the case, then eclipse may no longer be able to start (it needs to look for the JAVA_HOME variable from the environment variable, and the JAVA_HOME variable value has been changed from "j2sdk1.3" to "j2sdk1.4"). In the same way, the software jakarta-tomcat is upgraded frequently. Now that Tomcat is used in combination with eclipse, every time Tomcat is upgraded, the Tomcat installation directory may have to be reset in eclipse. If we follow the traditional installation method, we have to set up or configure each time we upgrade the software, which is very troublesome. For this kind of problem, the solution is very simple. Just remove the version number from the default software installation directory name (if you are worried about forgetting the version number, just add a readme file to the directory to explain). The above installation process uses this method.
(The latter part of writing the program should be deployed before you can see the page in the browser.)