MyEclipse Custom servlet templates

Source: Internet
Author: User

    • Every time you create a servlet with a template that myeclipse the default servlet, it generates a lot of unused code. Therefore, we can customize the servlet template. The steps are as follows:
    1. Locate the com.genuitec.eclipse.wizards_11.5.0.me201310291746.jar file in MyEclipse (i installed the MyEclipse Professional 2014) Under the installation directory under /plugins

    2. Open Com.genuitec.eclipse.wizards_11.5.0.me201310291746.jar and find templates .

    3. Into the templates inside there are servlet.java files, open, modify the code inside, you can define your own desired servlet template.

    • Open the Servlet.java file and modify the code inside to:    
1 <Aw:import>Java.io.IOException</Aw:import>2 <Aw:import>Java.io.PrintWriter</Aw:import>3 4 <Aw:import>Javax.servlet.ServletException</Aw:import>5 <Aw:import>Javax.servlet.http.HttpServlet</Aw:import>6 <Aw:import>Javax.servlet.http.HttpServletRequest</Aw:import>7 <Aw:import>Javax.servlet.http.HttpServletResponse</Aw:import>8 9 <Aw:parentclass>Javax.servlet.http.HttpServlet</Aw:parentclass>Ten  One <Aw:methodname= "Doget"> A Public void Doget (HttpServletRequest request, httpservletresponse response) - throws Servletexception, IOException { -  the     } -  - </Aw:method> -  + <Aw:methodname= "DoPost"> -      + Public void DoPost (HttpServletRequest request, httpservletresponse response) A throws Servletexception, IOException { at doget (request,response); -          -     } -  - </Aw:method>
View Code
    • The servlet is then created with the following style:
1  PackageCom.bookStore.web.servlet;2 3 Importjava.io.IOException;4 5 Importjavax.servlet.ServletException;6 ImportJavax.servlet.http.HttpServlet;7 Importjavax.servlet.http.HttpServletRequest;8 ImportJavax.servlet.http.HttpServletResponse;9 Ten  Public classLoginservletextendsHttpServlet { One  A      Public voiddoget (httpservletrequest request, httpservletresponse response) -             throwsservletexception, IOException { -  the     } -  -      Public voidDoPost (httpservletrequest request, httpservletresponse response) -             throwsservletexception, IOException { + doget (request, response); -  +     } A  at}
View Code

MyEclipse Custom servlet templates

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.