原Servlet模板实例

package www.csdn.net.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 First extends HttpServlet { /**
* Constructor of the object.
*/
public First() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// 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();
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
} }

怎样在建Servlet时去掉所有的注释:

先找到MyEclipse安装到哪

(1)右击MyEclipse

(2)复制目标(T)的路径,然后粘在计算机路径下进行搜索

(3)点击plugins文件

(4)搜寻这个文件

(5)打开文件找模版templates在template下再找servlet.java

(6)打开servlet.java在里面删除所有的注解

(7)在重新启动工具MyEclipse(注),在建一个新的servlet文件

在MyEclipse中怎么修改Servlet模板的更多相关文章

  1. myeclipse中如何修改Servlet模板_day01

    参考网址:https://jingyan.baidu.com/article/0eb457e536d5a503f1a90593.html 如果你在web项目下创建一个Servlet类,那么它会自带很多 ...

  2. JavaWeb学习之Servlet(二)----Servlet的生命周期、继承结构、修改Servlet模板

    [声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140466.html 一.http协议回顾: 在上一篇文章中:JavaW ...

  3. (转)JavaWeb学习之Servlet(二)----Servlet的生命周期、继承结构、修改Servlet模板

    [声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140466.html 一.http协议回顾: 在上一篇文章中:JavaW ...

  4. Myeclipse中如何修改Tomcat的端口号

    一,使用 Myeclipse 中自带的 tomcat 右键 configure 弹出窗口 在 port Number 中修改 端口号即可: 二,配置的 tomcat 如果用上述的方法,只能打开这样的窗 ...

  5. MyEclipse中修改servlet模板

    1.在MyEclipse目录下搜索com.genuitec.eclipse.wizards,得到搜索结果 com.genuitec.eclipse.wizards_8.4.100.me20091213 ...

  6. MyEclipse修改Servlet模板

    进入myeclipse的安装路径 然后进入plugins文件夹 打开搜索框,输入 *wizard* 找到名字是 com.genuitec.eclipse.wizards_11.5.0.me201310 ...

  7. Idea中修改servlet模板

    1.点击左上角的File: Setting --> Editor --> File and Code Templates --> Other --> web -->Ser ...

  8. 修改Servlet模板,让Servlet更清新

    每次新建一个Servlet,都会有很多的代码跟注释,但是在实际开发中我们是用不到这些的,所以每次都得手动删除,非常麻烦,所以接下来讲一下如何让自己的Servlet看上去更清新: 首先找到你的Myecl ...

  9. 修改Servlet模板

    1.找到jar文件 查看MyEclipse根目录下的myeclipse.ini,找到Common文件夹的位置,打开文件夹..\Common\plugins 找到文件 com.genuitec.ecli ...

随机推荐

  1. emacs之配置8,gdb调试设置

    emacsConfig/gdb-setting.el (global-set-key [(f5)] 'gud-go) (global-set-key [(f7)] 'gud-step) (global ...

  2. node使用JsonWebToken 生成token,完成用户登录、登录检测

    最近在用node做后台的登录,检测登录功能.在本地使用session可以成功,但是放服务器后发现session失效了,每次请求session都会变化,着了很久原因.原来,自己项目是前后端分离的,前端调 ...

  3. pytest框架 里 fixture 参数化的方法

  4. 32位汇编基础_cpu 寄存器

    32位通用寄存器 EAX EBX ECX EDX EBP ESP ESI EDI 八个寄存器都可以作为普通的数据寄存器使用.但有的有特殊的用途: EAX    为累加器, ECX    为计数器, E ...

  5. Bootstrap-CL:分页

    ylbtech-Bootstrap-CL:分页 1.返回顶部 1. Bootstrap 分页 本章将讲解 Bootstrap 支持的分页特性.分页(Pagination),是一种无序列表,Bootst ...

  6. postman-1版本区别、选择

    postman基于乙醇在腾讯课堂的postman教程 postman特点: 1.便于开发:开发接口的时候需要快速的调用接口,以便调试 2.便于测试:测试的时候需要非常方便的调用接口,通过不同的参数去测 ...

  7. [转]oracle 12c 中的分页子句

    转自:http://blog.itpub.net/271063/viewspace-1061279/ -- 连接数据库 创建测试用户-- Connected to Oracle Database 12 ...

  8. CFGym 101161I 题解

    一.题目链接 http://codeforces.com/gym/101161/problem/I 二.题意 给定一棵树,一个初始的省会城市,若干个询问,0表示修改省会城市,1表示查询去省会必须经过指 ...

  9. nodejs连接mongodb

    一.安装 a.访问mongodb官网下载https://www.mongodb.com/,有zip或者msi版本,zip解压缩就可以用,msi需要安装后使用 b.安装,指定好安装路径,一路下一步 c. ...

  10. css踩过的坑

    1. 英文内容会撑破容器而中文内容是可以自动换行的 原因: 因为数学规则因素,中文韩文朝鲜文等可以在任何字之后断行的,而英文却不能把一个单词拆开换行,只能撑破容器 解决: 用word-break: b ...