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

《Servlet学习笔记》Servlet 简介

时间:2015-02-10 01:59:33      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:servlet   servlet 简介   servlet学习笔记   

Servlet 简介:
Servlet是sun公司提供的一门用于开发动态web资源的技术。
Sun公司在其API中提供了一个servlet接口,用户若想开发一个动态web资源(即开发一个Java程序向浏览器输出数据),需要完成以下两步:
1.编写一个Java类,实现servlet接口;
2.把开发好的Java类部署到web服务器中。


jsp就是servlet
javase、javaee,servlet不属于javase而属于javaee
servlet专门文档API
Tomcat可以运行servlet,lib里面有servlet的jar包

用记事本或UltraEdit编写java程序,用Java、javac编译运行


http://tomcat.apache.org/tomcat-5.5-doc/servletapi/

public interface Servlet

Defines methods that all servlets must implement.

A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the HyperText Transfer Protocol.

To implement this interface, you can write a generic servlet that extends javax.servlet.GenericServlet or an HTTP servlet that extends javax.servlet.http.HttpServlet.

This interface defines methods to initialize a servlet, to service requests, and to remove a servlet from the server. These are known as life-cycle methods and are called in the following sequence:

    The servlet is constructed, then initialized with the init method.
    Any calls from clients to the service method are handled.
    The servlet is taken out of service, then destroyed with the destroy method, then garbage collected and finalized.

In addition to the life-cycle methods, this interface provides the getServletConfig method, which the servlet can use to get any startup information, and the getServletInfo method, which allows the servlet to return basic information about itself, such as author, version, and copyright.


Method Summary


 voiddestroy()
          Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
 ServletConfiggetServletConfig()
          Returns a ServletConfig object, which contains initialization and startup parameters for this servlet.
 java.lang.StringgetServletInfo()
          Returns information about the servlet, such as author, version, and copyright.
 voidinit(ServletConfig config)
          Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
 voidservice(ServletRequest req,        ServletResponse res)
          Called by the servlet container to allow the servlet to respond to a request.


《Servlet学习笔记》Servlet 简介

标签:servlet   servlet 简介   servlet学习笔记   

原文地址:http://zlfwmm.blog.51cto.com/5892198/1613177

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