Java Create Web Project

Source: Internet
Author: User

Download the Tomcat service first to run Java programs similar to IIS in Windows

: tomcat.apache.org, it is best to download the zip compression version, after decompression can be used directly. Such as:

The following creates a "Dynamic Web project", such as:

Create a good directory such as:

Add a servlet to the project. Steps: Right-click on "src" > New >servlet, fill in the Java Packages (package name) and class name (class name) Two, then click Next to finish.

If you create a servlet page HttpServletRequest error, most of the missing Servlet-api.jar package, you can find it from the Tomcat Lib folder and copy it to the Lib folder under Web-int in the project, as

The code in Demo.java is as follows (after removing the useless code)

Package Test;import Java.io.ioexception;import Javax.servlet.servletexception;import Javax.servlet.annotation.webservlet;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import javax.servlet.http.httpservletresponse;/* * @ Webservlet is the URL address of the servlet * do not need to go to the Web. Xml to configure the servlet information * */@WebServlet ("/demo.html") public class Demo extends HttpServlet {private static final long serialversionuid = 1l;protected void doget (HttpServletRequest request, HttpServlet Response Response) throws Servletexception, IOException {response.getoutputstream (). Write ("Hello". GetBytes ());} protected void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { Doget (request, Response);}}

Post-run interface such as

Java Create Web Project

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.