Eclipse Development Web Project

Source: Internet
Author: User

Eclipse Development Web Project

1. Development environment ...-1-

1.1. Development tools ...-1-

1.2. Build the development environment ...-1-

2. Developing Web Projects ...-1-

2.1. New Web Project ...-1-

2.2. Development of Servlet-3-

2.3. Publish Web Project ...-5-

2.4. Develop JSP.    -7- 1. development of the environment to build 1.1. Development tools

Jdk:jdk1.6.0_17

Web server:apache-tomcat-6.0.26

IDE:ECLIPSE-JEE-HELIOS-SR1 1.2. Build the development environment

By choosing the IDE as a tool for development, the IDE can manually configure the plug-in tools you need, so it's easy and quick to build your development environment.

(1) Install JDK

Tip: You need to configure environment variables after installing the JDK.

(2) Install Tomcat

Tip: If it is uncompressed version of the direct decompression on OK, if the installation version needs to be installed according to installation prompts to complete. Because you are using the IDE for development, you do not need to configure Tomcat environment variables, but it is recommended that you do not rely too much on the IDE.

(3) Extract eclipse

Tip: If you do not have the JDK installed, you will not be able to complete the eclipse installation.

Well, the development environment here is ready, and then a demo will show you how to develop Web projects in eclipse.  2. Develop Web project 2.1. New Web project

Eclips-->file-->new-->dynamic Web Project

Select the new runtime Configuration Web Server under Targetruntime

Next>

Select the Tomcat installation directory via browse

Tip: Note that the JRE version of Tomcat is consistent with the JRE version of Project

Finish>

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

the new Web project structure is as follows 2.2. Developing a servlet

Right-click on src on Projectexplorer view to select New-->servlet

Next> .....

Choose to rewrite the service method so that the code can be automatically generated easily

Of course, you can write the servlet all manually, but don't forget to configure the servlet in Web.xml, hehe ^_^

Then finish completes the creation of the servlet

Hello.java's source code is as follows

Package Org.wenlong

 

Import java.io.IOException;

Import javax.servlet.ServletException;

Import Javax.servlet.http.HttpServlet;

Import javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse;

 

Public class Hello extends HttpServlet {

 

       protected void Service (HttpServletRequest request,

                      httpservletresponse response) throws Servletexception, IOException {

              System.out.println ("Hello Servlet");

 

      }

 

 


Demo code is so simple, hehe ^_^ 2.3. Publish a Web project

Web project is created, and the next step is to publish the Web project in the Web server

Window-->show views-->servers

Right-in the blank area of the servers view

New-->server

After finish, you can start tomcat under the servers.

A lot of Tomcat startup information is printed out of the console after Tomcat is started

If no exception appears, the demo is successful

It doesn't matter even if a warning message appears

Accessing Http://localhost:8080/demo/Hello in the browser

If exception information is not present and output in console

Hello Servlet

Indicates that the servlet test succeeded ^_^

just do a very simple demo, to explain the problem on the OK 2.4. Develop JSP

Create a new JSP File under the WebContent directory

After next>, you finish directly.

Index.jsp's source code is as follows

 

<%@ page language= "java" Conten Ttype= "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>

<meta http-equiv= "Content-type" content= "text/html; charset=iso-8859-1" >

<title>insert title here</title>

<body>

</body>

 

 

 

 

 

 

 

 

  [

, [] /p>

 

 

Re-deploy the demo project to see the effect.

 

Java EE water is very deep, want to become a Java EE engineer, but also continue to work hard

 

Come on!

 

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.