Introduction to Eclipse Development Web project

Source: Internet
Author: User
Tags tomcat

Foreword: Used to use MyEclipse 8 to develop the web, use Eclipse intentionally today, so in this small remember, one has the need to refer to, second, and then casually make a note reserve

(Reprint please explain source: http://blog.csdn.net/ldw4033/article/details/18313281)1. Development of the environment to build 1.1. Development toolsJdk:jdk1.6.0_17
Web server:apache-tomcat-6.0.37
Ide:eclipse-jee
1.2. Build the development environmentBy 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 JDKTip: You need to configure environment variables after installing the JDK.
(2) Install TomcatTip: 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 EclipseTip: 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. Developing Web Projects 2.1. New Web ProjectEclipse-->file-->new-->dynamic Web Project, as shown in Figure 1:
Figure 1 If you do not have or eclipse-->file-->new-------->web-->otherdynamic Web Project, such as Figure 2, 3:


Figure 2 Figure 3
Select the new runtime Configuration Web Server under Target runtime

Next>
Select the Tomcat installation directory via browse
Finish>
After that, all the way to next until finish is OK.
The new Web project structure is as follows
2.2. Developing a servletRight-click on SRC on Project Explorer view to select New-->servlet
Next&gt .....

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

Helloservlet.java's source code is as follows

Package com.lanyoung.servlet;
Import java.io.IOException;
Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse;  /** * Servlet Implementation Class HelloServlet/public class HelloServlet extends HttpServlet {private static final
       
    Long serialversionuid = 1L;
    /** * @see httpservlet#httpservlet () * * * Public helloservlet () {super (); /** * @see Httpservlet#doget (httpservletrequest request, httpservletresponse response) * * protected void doget (Ht Tpservletrequest request, HttpServletResponse response) throws Servletexception, IOException {System.out.println ("
	Hello JSP "); /** * @see Httpservlet#dopost (httpservletrequest request, httpservletresponse response) * * protected void DoPost ( HttpServletRequest request, HttpServletResponse response) throws Servletexception, IOException {this.doget (request, RE
	Sponse); }

} 

Demo code is so simple, hehe ^_^
2.3. Publish Web Project Web project is created, and the next step is to publish the Web project in Web server
Window-->show Views-->servers
Right-click in the blank area of Servers view
New-->server
 



 
 
After finish, you can start Tomcat under Servers
  starts Tomcat and prints out a lot of Tomcat startup information under the console
If no exception appears, the demo publication succeeds
It doesn't matter if you have a warning message
Access Http://localhost:8080/HelloWorld/HelloServlet in Browser
If exception information is not present and the
Hello JSP is output in console
indicates that the servlet test was successful ^_^
just made a very simple demo, stating that the problem is OK
2.4. Development JSP new JSP File
in webcontent directory  
&NBSP
Next> directly after the
Index.jsp source code 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" >

Re-deploy the demo project to see the effect

(Reprint please explain source: http://blog.csdn.net/ldw4033/article/details/18313281)
Above..
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.