MyEclipse servlet Template Replacement

Source: Internet
Author: User

When creating a servlet with MyEclipse, the generated class looks depressing, the Dopost method and the Doget method in it are commented, and the contents have already been written, how to modify it?

First, search for com.genuitec.eclipse.wizardsin the MyEclipse installation directory to search for the results:



Com.genuitec.eclipse.wizards_11.0.0.me201303311935.jar(different versions of MyEclipse this file name may be different at the end) This jar file is the file we're looking for, Then open this file and find the Servlet.java file in the templates directory of the jar file , which is the template file used by MyEclipse when creating the servlet, and the next step is to modify the file. It is recommended to make a backup of this file before modifying it. Copy the file, then open it with the editor, and take a look at the file, the line starting with # should be some comment information,<aw:import> represents the package to be imported,<aw:parentclass> Represents the parent class that the servlet inherits, <aw:constructor represents the constructor, <aw:method represents the declaration of the method, and after that, ok! Start modifying it. Find <aw:method name= "Doget" > Replace the contents of Doget method with Dopost (request, response); and delete the above Javadoc, and then find <aw:method name= "DoPost" > The contents of the method body removed, and remove Javadoc, and finally clean up the import package. I put out the results of my last modification, if there is a need to modify some of the things, the following is mainly for the convenience of people to view:


File name: Servlet.java

#---------------------------------------------# # <aw:description>template for Servlet</aw:description ># <aw:version>1.1</aw:version># <aw:date>04/05/2003</aw:date># <aw:author> Ferret renaud</aw:author>#---------------------------------------------#<aw:import> Java.io.ioexception</aw:import><aw:import>javax.servlet.servletexception</aw:import><aw: Import>javax.servlet.http.httpservlet</aw:import><aw:import> Javax.servlet.http.httpservletrequest</aw:import><aw:import>javax.servlet.http.httpservletresponse </aw:import><aw:parentclass>javax.servlet.http.httpservlet</aw:parentclass><aw: Constructor name= "C1" >/** * constructor of the object. */public <aw:className/> () {super ();} </aw:constructor> <aw:method name= "Doget" >/** * The Doget method of the servlet. <br> * This method was called when a form have its tag value method equals to get. * * @parAM request the request send by the client to the server * @param response the response send by the server to the client * @throws servletexception If an error occurred * @throws IOException If an error occurred */public void Doget (httpservletre Quest request, HttpServletResponse response) throws Servletexception, IOException {doPost (request, response);} </aw:method><aw:method name= "DoPost" >/** * The DoPost method of the servlet. <br> * This method was called when a form have its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the Client * @throws servletexception If an error occurred * @throws IOException If an error occurred */public void DoPost (HTT Pservletrequest request, HttpServletResponse response) throws Servletexception, IOException {}</aw:method>< Aw:method name= "DoPut" >/** * The DoPut method of the servlet. <br> * This method was called when aHTTP put request is received. * * @param request the request send by the client to the server * @param response the response send by the server to the Client * @throws servletexception If an error occurred * @throws IOException If an error occurred */public void DoPut (Http ServletRequest request, HttpServletResponse response) throws Servletexception, IOException {//Put your code HERE}&LT;/AW : Method><aw:method name= "DoDelete" >/** * The DoDelete method of the servlet. <br> * This method was called when a HTTP delete request is received. * * @param request the request send by the client to the server * @param response the response send by the server to the Client * @throws servletexception If an error occurred * @throws IOException If an error occurred */public void DoDelete (H Ttpservletrequest request, HttpServletResponse response) throws Servletexception, IOException {//Put your code here}< /aw:method><aw:method name= "Init" >/** * initialization of the servlet. <br> * * @throws servletexception If an error occurs */public void init () throws Servletexception {//Put your code Here}</aw:method><aw:method name= "Destroy" >/** * destruction of the servlet. <br> */public void Destroy () {Super.destroy ();//Just puts "destroy" string in log//Put your code Here}</aw:met  Hod><aw:method name= "Getservletinfo" >/** * Returns information about the servlet, such as * author, version, and  Copyright. * * @return String information about this servlet */public String getservletinfo () {return ' This is my default servlet cre Ated by Eclipse ";} </aw:method>


MyEclipse servlet Template Replacement

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.