Configure eclpise + Tomcat and compile and deploy JSP

Source: Internet
Author: User
The subject of this thesis is the feature extraction algorithm of key frames. It requires a demo, which should be built on the Web service system and use JSP dynamic pages as the interface. After consideration, we decided to use the popular Java Development Platform eclipse and Tomcat server as development tools. However, the configuration and use of these two software is not as convenient and simple as commercial Java ide such as jbulider, and there are not many Chinese books on configuration methods. After a period of exploration, as well as the collection of information on the Internet, and many practices, the two software were finally configured successfully, and the compilation and deployment of a simple JSP dynamic page was realized, it creates conditions for system compilation in the future. The specific process is as follows (the software versions installed and configured below are all relatively new or stable ):

1. Download
J2sdk download
Http://java.sun.com/j2se/1.4.2/download.html
Download version is j2sdk-1_4_2_08

Download eclipse
Http://www.eclipse.org/downloads/index.php
Download version is eclipse-SDK-3.0.2-win32

Download Eclipse plug-in
Chinese package:
Http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/L-3.0.1_Translations-200409161125/NLpack-eclipse-SDK-3.0.x-win32.zip
Tomcat plug-in sysdeo eclipse Tomcat launcher Plugin:
Http://www.sysdeo.com/eclipse/tomcatPluginV3.zip

Tomcat download
Http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
Download version is jakarta-tomcat-5.0.28

Ii. Installation
1. Install j2sdk first
My installation path is: D:/program files/Java/j2sdk

2. Install eclipse again
Eclipse is a green software and does not need to be installed. You can decompress the downloaded eclipse package.
My installation path is: D:/program files/Java/eclipse

3. install Tomcat
Download the installation file and follow the installation instructions.
My installation path is: D:/program files/Java/tomcat

4. Install the Eclipse plug-in
Chinese pack
Directly decompress the contents in the features and plugins folders in the compressed package NLpack-eclipse-SDK-3.0.x-win32 to the same name folder in the eclipse folder.
Tomcat plug-in
Decompress the package tomcatpluginv3 and extract the content in the plugins folder to the folder with the same name in the eclipse folder.

Iii. Environment Configuration
1. system environment variable configuration
Right-click "my computer"-> advanced-> environment variable,
Set the java_home variable to the directory "D:/program files/Java/j2sdk" installed on it ";
The tomcat_home variable points to the installed directory "D:/program files/Java/tomcat ";
The PATH variable contains "% java_home %/bin ;";
The classpath variable contains "% java_home %/lib/tools. jar ;";

2. Java Runtime Environment configuration in eclipse
In the main eclipse window, choose "window"> "preference"> "Java"> "installed JRE" and select the j2sdk we have installed.

3. Configure the sysdeo Tomcat plug-in
In the main eclipse window, choose "window"> "preference"> "Tomcat". Select "version 5.x" for tomcat version (the version we have installed). Enter the path for installing Tomcat in Tomcat home. Here is D: /program files/Java/tomcat.
Switch to the advanced option, and enter the tomcat installation path at Tomcat base. Here is D:/program files/Java/tomcat.
Switch to the JVM setting option and make sure that JRE is the j2sdk version you have installed. Here we select j2sdk.
Switch to the Tomcat manger app and add a user to the management interface.
Finally, press the Apply button and then confirm.
Check whether the configuration is successful. In the main eclipse window, press the Tomcat run button and enter http: // localhost: 8080 in the address bar of the browser. If the Tomcat page appears, the configuration is successful.

4. Programming
1. Create a tomcat Project
Right-click the blank area in the "package Resource Manager" window, choose "CREATE"> "Tomcat Project", enter the project name in the project name, enter tomcat_test here, and click "finish.

2. Create a JSP page
In package explorer, right-click tomcat_test, create a file, and enter helloworld. jsp in the file name (the extension cannot be missing). In the text editing window, enter the following code:
<HTML>
<Head>
</Head>

<Body>
<H1> Hello World </Body>

</Html>

Save the settings.

3. Click "Run Tomcat ".

4. If everything works, enter http: // localhost: 8080/atat_test/helloworld. jsp in the browser window.

The browser displays "Hello World"

5. Deploy the JSP page
The deployment here is a simple method: first, copy the above to the tomcat_test directory in the workpalce directory of eclipse to the webapps directory under the Tomcat directory, and then to the server in the conf directory. XML for text editing, add the following host element before </engin>:
<Host name = "*. *" DEBUG = "0" appbase = "webapps"
Unpackwars = "true" autodeploy = "true">
</Host>
Then save and start Tomcat, as long as you enter http: // *. *: 8080/tomcat_test/helloworld. jsp in the browser window
The browser displays "Hello World"
This shows that your JSP page is successfully deployed and published, and someone else can access your page online.
(PS: *. * indicates the IP address of the host where the Tomcat server is installed)

Vi. Notes
(1) Select j2sdk instead of JRE because j2sdk has a Java Runtime Environment and classes required by Java programs, while JRE only has a runtime environment.
(2) due to frequent software upgrades, you often need to reset the environment variables or reconfigure them. For example, you can upgrade 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 so, eclipse may not be able to start any more (it needs to find the java_home variable from the environment variable, the java_home variable value has been changed from j2sdk1.3 to j2sdk1.4 ). Likewise, the software of Jakarta-Tomcat is frequently upgraded. Now, Tomcat is used in combination with eclipse. Therefore, you may need to reset the tomcat installation directory in eclipse for each Tomcat upgrade. If we follow the traditional installation method, we need to set or configure the software every time we upgrade it, which is very troublesome. The solution to this problem is simple. You only need to remove the default software installation directory name from the version number (if you are worried about forgetting the version number, you only need to add a ReadMe file to the directory to describe it ). This method is used in the above installation process.
(3) the above description is based on some books and a lot of online materials and recorded after my own practices. There may be many shortcomings, at the same time, I would like to thank the experts who posted materials online. I have benefited a lot from their articles.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.