MyEclipse Servlet 模板修改
来源:互联网 发布:老男孩linux运维 编辑:程序博客网 时间:2024/05/18 13:25
(MyEclipse 8.6 + Ubuntu 12.10 + apache-tomcat-7.0.32 + jdk1.7.0_07 )
未修改过的Servlet :
import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class TestServlet extends HttpServlet {/** * Constructor of the object. */public TestServlet() {super();}/** * Destruction of the servlet. <br> */public void destroy() {super.destroy(); // Just puts "destroy" string in log// Put your code here}/** * The doDelete method of the servlet. <br> * * This method is 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// Put your code here}/** * The doGet method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html");PrintWriter out = response.getWriter();out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");out.println("<HTML>");out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");out.println(" <BODY>");out.print(" This is ");out.print(this.getClass());out.println(", using the GET method");out.println(" </BODY>");out.println("</HTML>");out.flush();out.close();}/** * The doPost method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html");PrintWriter out = response.getWriter();out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");out.println("<HTML>");out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");out.println(" <BODY>");out.print(" This is ");out.print(this.getClass());out.println(", using the POST method");out.println(" </BODY>");out.println("</HTML>");out.flush();out.close();}/** * The doPut method of the servlet. <br> * * This method is called when a HTTP 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// Put your code here}/** * 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 created by Eclipse";}/** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */public void init() throws ServletException {// Put your code here}}
Servlet 模板;(存放位置:/Genuitec/Common/plugins/com.genuitec.eclipse.wizards_8.6.0.me201007140905.jar)
com.genuitec.eclipse.wizards_8.6.0.me201007140905/templates/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>java.io.PrintWriter</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 is called when a form has 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html");PrintWriter out = response.getWriter();out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");out.println("<HTML>");out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");out.println(" <BODY>");out.print(" This is ");out.print(this.getClass());out.println(", using the GET method");out.println(" </BODY>");out.println("</HTML>");out.flush();out.close();}</aw:method><aw:method name="doPost">/** * The doPost method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/html");PrintWriter out = response.getWriter();out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");out.println("<HTML>");out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");out.println(" <BODY>");out.print(" This is ");out.print(this.getClass());out.println(", using the POST method");out.println(" </BODY>");out.println("</HTML>");out.flush();out.close();}</aw:method><aw:method name="doPut">/** * The doPut method of the servlet. <br> * * This method is called when a HTTP 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// Put your code here}</aw:method><aw:method name="doDelete">/** * The doDelete method of the servlet. <br> * * This method is 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(HttpServletRequest 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:method><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 created by Eclipse";}</aw:method>
修改之后(模板代码):
#---------------------------------------------## <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>java.io.PrintWriter</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 is called when a form has 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {}</aw:method><aw:method name="doPost">/** * The doPost method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {}</aw:method><aw:method name="doPut">/** * The doPut method of the servlet. <br> * * This method is called when a HTTP 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(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {// Put your code here}</aw:method><aw:method name="doDelete">/** * The doDelete method of the servlet. <br> * * This method is 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(HttpServletRequest 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:method><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 created by Eclipse";}</aw:method>
新建一个纯净版的Servlet:
代码:
import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class Test2Servlet extends HttpServlet {/** * Constructor of the object. */public Test2Servlet() {super();}/** * Destruction of the servlet. <br> */public void destroy() {super.destroy(); // Just puts "destroy" string in log// Put your code here}/** * The doDelete method of the servlet. <br> * * This method is 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// Put your code here}/** * The doGet method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}/** * The doPost method of the servlet. <br> * * This method is called when a form has 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}/** * The doPut method of the servlet. <br> * * This method is called when a HTTP 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(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// Put your code here}/** * 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 created by Eclipse";}/** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */public void init() throws ServletException {// Put your code here}}
- MyEclipse Servlet 模板修改
- MyEclipse 修改servlet模板
- MyEclipse 修改servlet模板
- MyEclipse 修改Servlet模板
- myeclipse修改servlet模板
- MyEclipse修改Servlet模板
- Myeclipse怎样修改servlet模板
- 修改 MyEclipse 的servlet 模板
- 修改MyEclipse的servlet模板
- 修改MyEclipse中servlet模板
- Myeclipse修改servlet模板教程
- MyEclipse中修改Servlet和Jsp模板
- MyEclipse中修改Servlet和Jsp模板
- myeclipse中修改servlet的模板代码
- 在MyEclipse中怎么修改Servlet模板
- Myeclipse修改Servlet模板类操作
- MyEclipse 8.5 下修改servlet,jsp 模板
- 在MyEclipse中怎么修改Servlet模板
- js
- IT学子成长指导类文章链接(一)
- 【算法设计】矩阵乘法
- js 设计模式 第十四章 Proxy Pattern
- codeforces 238A
- MyEclipse Servlet 模板修改
- HTML文档对象的事件及JS函数解析
- MFC札记
- Windows核心编程——第7章 线程调度
- BMP文件格式详解(BMP file format)
- 什么是网站流量?
- 如何使用gdb调试C程序
- Linux 下zip包的压缩与解压
- 一些简单的批处理脚本记录