Set up a JSP running environment (EclipseforjavaEEDevelopers + Tomcat7.0.79 ),

Source: Internet
Author: User

Set up a JSP running environment (EclipseforjavaEEDevelopers + Tomcat7.0.79 ),

If you want to use the free Java ee ide and find it too difficult to download the MyEclipse cracked version, consider Eclipse for java EE Developers.

1. Download Eclipse for java EE Developers

Eclipse for java EE Developers official download URL: https://www.eclipse.org/downloads/eclipse-packages/

You can choose to download files based on your computer's system type.

2. Download Tomcat

Go to the Tomcat official website https://tomcat.apache.org/to download the Tomcat repository you want to download.

Remember the decompressed path and use it later.

3. Embed Tomcat into Eclipse

A. decompress the Eclipse installation package, a folder named eclipse is generated, and the icon in the folder is displayed.

B. The following prompt box appears, asking you to select the storage address of the project you created.

C. Click launch to enter the main interface, and then click Window> Show View> Other... -> Server-> click Open below

D. After the above steps, the window below the main interface will jump out of the Servers module, such:

Click the font in blue to display the following interface:

Click Apache-> select the Tomcat version you downloaded-> Click Browse... Select the path where you have extracted Tomcat.

Click Finish.

4. Create an example project:

A. File-> Dynamic Web Project-> Fill in the Project name (do not click Finish directly, click Next and then click Next)-> check the following options (in this case, the/WebContent/WEB-INF directory of the project will have web. xml configuration file)

B. In addition, you need to put the jsp-api.jar and servlet-api.jar In the lib folder under the Tomcat installation directory into the lib folder of the project, or add them to the CLASSPATH environment variable. Otherwise, the browser will jump out of the 404 error when parsing and running the servlet.

(The following content is taken from instructor Li Gang's lightweight Enterprise Java EE Enterprise Application Practice.)

C. Starting from Servlet3.0, you can configure Servlet in two ways.

1. Use @ WebServlet Annotation in the Servelt class for configuration;

2. Configure in the web. xml file.

If you plan to use Annotation to configure the Servlet, pay attention to the following two points:

* Do not specify metadata-complete = "true" in the root element () of the web. xml file ".

* Do not configure the Servlet in the web. xml file.

If you want to use the web. xml file to configure the Servlet, You need to configure the following two parts.

* Configure the Servlet name: corresponding to the elements in the web. xml file.

* Configure the Servlet URL: it corresponds to the elements in the web. xml file. If no URL is configured for the Servlet, the Servlet cannot respond to user requests.

(Note: The values of the two labels must be the same, because the Servlet ing between the Servlet class () and address () is built for the bridge)

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.