码迷,mamicode.com
首页 > 系统相关 > 详细

Eclipse -- Servlet demo创建

时间:2020-06-29 15:26:55      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:mys   close   span   content   html   xtend   vax   pre   http   

前期准备

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>");
    }

}
View Code

 

技术图片

Eclipse -- Servlet demo创建

标签:mys   close   span   content   html   xtend   vax   pre   http   

原文地址:https://www.cnblogs.com/tom2015010203/p/13207965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!