Create a WEB Project

Source: Internet
Author: User

Eclipse Web Development Project

  I. Establishment of Development Environment1. Development Tools

JDK: jdk1.6.0 _ 17

Web server: APACHE-Tomcat-6.0.26

IDE: eclipse-jee-helios-SR1

2. Build a Development Environment

Because IDE is selected as the development tool, IDE can manually configure the required plug-in tool, so it is easy and quick to build a development environment.

(1) install JDK

Tip: After JDK is installed, You need to configure environment variables.

(2) install Tomcat

Tip: if the version is decompressed, decompress it directly. if the version is installed, complete the installation as prompted. Because IDE is used for development, you do not need to configure Tomcat environment variables. However, we recommend that you do not rely too much on IDE.

(3) decompress eclipse

Tip: If JDK is not installed, eclipse installation cannot be completed.

Now, the development environment is ready. Next, we will use a demo to demonstrate how to develop a web project in eclipse.

2. Develop a web project 1. Create a WEB Project

Eclips --> file --> New --> dynamic web project

Select New runtime under targetruntime to configure Web Server

Next>

Use browse to select the tomcat installation directory

Tip: note that the JRE version of Tomcat must be consistent with the JRE version of the project.

Finish>

After that, all the way to next until finish is OK.

The new web project structure is as follows:

 

2. Develop Servlet

Right-click the src in the projectexplorer view and choose new --> servlet.

Next> ......

Select the override service method to automatically generate code.

Of course, you can also manually compile the servlet, but do not forget to configure the servlet in Web. xml.

Then finish the servlet creation.

The source code of Hello. Java is as follows:

 

The Demo code is as simple as this.

3. Publish a WEB Project

After the WEB Project is created, the next task is to release the WEB Project on the Web server.

Window --> show views --> servers

Right-click the blank area of the servers view

New --> Server

After finishing, you can start Tomcat under servers.

After Tomcat is started, many Tomcat startup information is printed in the console.

If no exception occurs, the demo is successfully released.

It does not matter even if a warning message appears.

Access http: // localhost: 8080/demo/hello in the browser

If no exception information is displayed

Hello Servlet

Successfully tested servlet. ^_^

I just made a very simple demo and explained the problem.

Create a JSP file in the webcontent directory

Next> finish

The source code of index. jsp is as follows:

<% @ Page Language ="Java"Contenttype ="Text/html; charset = ISO-8859-1"

Pageencoding =ISO-8859-1"%>

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">

<HTML>

<Head>

<Meta http-equiv ="Content-Type"Content ="Text/html; charset = ISO-8859-1">

<Title> insert title here </title>

</Head>

<Body>

<H1 align ="Center"> Hello JSP

</Body>

</Html>

 

 

 

 

Redeploy the demo project to see the effect.

 

Javaee has a deep water supply. To become a javaee engineer, we must continue to work hard.

JDK: jdk1.6.0 _ 17

Web server: APACHE-Tomcat-6.0.26

IDE: eclipse-jee-helios-SR1

2. Build a Development Environment

Because IDE is selected as the development tool, IDE can manually configure the required plug-in tool, so it is easy and quick to build a development environment.

(1) install JDK

Tip: After JDK is installed, You need to configure environment variables.

(2) install Tomcat

Tip: if the version is decompressed, decompress it directly. if the version is installed, complete the installation as prompted. Because IDE is used for development, you do not need to configure Tomcat environment variables. However, we recommend that you do not rely too much on IDE.

(3) decompress eclipse

Tip: If JDK is not installed, eclipse installation cannot be completed.

Now, the development environment is ready. Next, we will use a demo to demonstrate how to develop a web project in eclipse.

2. Develop a web project 1. Create a WEB Project

Eclips --> file --> New --> dynamic web project

Select New runtime under targetruntime to configure Web Server

Next>

Use browse to select the tomcat installation directory

Tip: note that the JRE version of Tomcat must be consistent with the JRE version of the project.

Finish>

After that, all the way to next until finish is OK.

The new web project structure is as follows:

 

2. Develop Servlet

Right-click the src in the projectexplorer view and choose new --> servlet.

Next> ......

Select the override service method to automatically generate code.

Of course, you can also manually compile the servlet, but do not forget to configure the servlet in Web. xml.

Then finish the servlet creation.

The source code of Hello. Java is as follows:

 

The Demo code is as simple as this.

3. Publish a WEB Project

After the WEB Project is created, the next task is to release the WEB Project on the Web server.

Window --> show views --> servers

Right-click the blank area of the servers view

New --> Server

After finishing, you can start Tomcat under servers.

After Tomcat is started, many Tomcat startup information is printed in the console.

If no exception occurs, the demo is successfully released.

It does not matter even if a warning message appears.

Access http: // localhost: 8080/demo/hello in the browser

If no exception information is displayed

Hello Servlet

Successfully tested servlet. ^_^

I just made a very simple demo and explained the problem.

Create a JSP file in the webcontent directory

Next> finish

The source code of index. jsp is as follows:

<% @ Page Language ="Java"Contenttype ="Text/html; charset = ISO-8859-1"

Pageencoding =ISO-8859-1"%>

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">

<HTML>

<Head>

<Meta http-equiv ="Content-Type"Content ="Text/html; charset = ISO-8859-1">

<Title> insert title here </title>

</Head>

<Body>

<H1 align ="Center"> Hello JSP

</Body>

</Html>

 

 

 

 

Redeploy the demo project to see the effect.

 

Javaee has a deep water supply. To become a javaee engineer, we must continue to work hard.

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.