码迷,mamicode.com
首页 > 其他好文 > 详细

实现Servlet接口来开发Servlet程序

时间:2018-04-17 14:22:15      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:实现Servlet接口来开发Servle

import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; //实现Servlet接口来开发Servlet程序 public class Demo3 implements Servlet { @Override public void destroy() { // TODO Auto-generated method stub } @Override public ServletConfig getServletConfig() { // TODO Auto-generated method stub return null; } @Override public String getServletInfo() { // TODO Auto-generated method stub return null; } @Override public void init(ServletConfig arg0) throws ServletException { // TODO Auto-generated method stub } @Override public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { //取得服务端向浏览器的输出流对象 PrintWriter pw = response.getWriter(); pw.write("welcome to java web coure!"); } }

web.xml

<servlet>
    <servlet-name>Demo3</servlet-name>
    <servlet-class>cn.web.http.Demo3</servlet-class>
  </servlet>

      <servlet-mapping>
    <servlet-name>Demo3</servlet-name>
    <url-pattern>/Demo3</url-pattern>
  </servlet-mapping>

技术分享图片

实现Servlet接口来开发Servlet程序

标签:实现Servlet接口来开发Servle

原文地址:http://blog.51cto.com/357712148/2104355

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