Eclipse -- Servlet demo创建
Posted tom2015010203
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eclipse -- Servlet demo创建相关的知识,希望对你有一定的参考价值。
前期准备
1.eclipse下载配置
2.tomcat下载配置
package com.zlj; 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 MyServletDemo extends HttpServlet { /** * */ private static final long serialVersionUID = 4453896088111078312L; private String mymsg; public void init() throws ServletException { mymsg = "Hello World!"; } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub // super.doGet(req, resp); resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.println("<h1>" + mymsg + "</h1>"); } }
以上是关于Eclipse -- Servlet demo创建的主要内容,如果未能解决你的问题,请参考以下文章