New Features of Servlet3.0 (Tomcat7.0 and later) and new features of servlet3.0

Source: Internet
Author: User

New Features of Servlet3.0 (Tomcat7.0 and later) and new features of servlet3.0
@ WebServlet

 

Function

After a Servlet is created in Eclipse, Eclipse does not automatically generate the ing information of the Servlet in web. xml, but adds the annotation @ WebServlet to the Servlet code.

@ WebServlet is used to declare a class as Servlet. This annotation will be processed by the container during deployment, and the container will deploy the corresponding class as Servlet according to the specific attribute configuration.

 

Use
// Corresponds to the content in the servlet tag in the old version
@ WebServlet (displayName = "This is ForwordServlet", // description name = "ForwordServlet", // servlet name urlPatterns = {"/forwordServlet"}, // url loadOnStartup = 1, // startup Item initParams ={@ WebInitParam (name = "username", value = "James")} // initialize the parameter) public class ForwordServlet extends HttpServlet {private static final long serialVersionUID = 1L;/*** @ see HttpServlet # doGet (HttpServletRequest request, HttpServletResponse * response) */protected void doGet (HttpServletRequest request, httpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stub response. getWriter (). append ("Served :"). append (request. getContextPath ());}}

 

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.