public interface Servlet {
/**
* Called by the servlet container to indicate to a servlet that the
* servlet is being placed into service.
* <p>The servlet container calls the <code>init</code>
* method exactly once after instantiating the servlet.
* The <code>init</code> method must complete successfully
* before the servlet can receive any requests.
* <p>The servlet container cannot place the servlet into service
* <li>Throws a <code>ServletException</code>
* <li>Does not return within a time period defined by the Web server
* </ol>
* @param config a <code>ServletConfig</code> object
* containing the servlet's
* configuration and initialization parameters
* @exception ServletException if an exception has occurred that
* interferes with the servlet's normal
* operation
* @see UnavailableException
* @see #getServletConfig
*/
//servlet一旦被实例化servlet容器开始调用init函数
public void init(ServletConfig config) throws ServletException;
//返回一个ServletConfig对象,包含了此Servlet的初始化和启动参数
public ServletConfig getServletConfig();
/**
* Called by the servlet container to allow the servlet to respond to
* a request.
*
* <p>This method is only called after the servlet's <code>init()</code>
* method has completed successfully.
*
* <p> The status code of the response always should be set for a servlet
* that throws or sends an error.
*
*
* <p>Servlets typically run inside multithreaded servlet containers
* that can handle multiple requests concurrently. Developers must
* be aware to synchronize access to any shared resources such as files,
* network connections, and as well as the servlet's class and instance
* variables.
* More information on multithreaded programming in Java is available in
* <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">
* the Java tutorial on multi-threaded programming</a>.
*
*
* @param req the <code>ServletRequest</code> object that contains
* the client's request
*
* @param res the <code>ServletResponse</code> object that contains
* the servlet's response
*
* @exception ServletException if an exception occurs that interferes
* with the servlet's normal operation
*
* @exception IOException if an input or output exception occurs
*
*/
//servlet容器调用允许回复一个请求,Servlet通常运行在一个多线程的Servlet容器中,可以同时处理多个请求,开发者要注意某些资源(文件、类、实例)的同步问题。
public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException;
/**
* Returns information about the servlet, such
* as author, version, and copyright.
*
* <p>The string that this method returns should
* be plain text and not markup of any kind (such as HTML, XML,
* etc.).
*
* @return a <code>String</code> containing servlet information
*
*/
//返回servlet的信息,比如作者,版本,版权
public String getServletInfo();
/**
*
* Called by the servlet container to indicate to a servlet that the
* servlet is being taken out of service. This method is
* only called once all threads within the servlet's
* <code>service</code> method have exited or after a timeout
* period has passed. After the servlet container calls this
* method, it will not call the <code>service</code> method again
* on this servlet.
*
* <p>This method gives the servlet an opportunity
* to clean up any resources that are being held (for example, memory,
* file handles, threads) and make sure that any persistent state is
* synchronized with the servlet's current state in memory.
*
*/
//被servlet container调用,从服务中去掉
public void destroy();
}
分享到:
相关推荐
"java-servlet-hello"例子是一个初学者常用的教程,旨在帮助理解Servlet的基本工作原理和如何在实际中运用。在这个例子中,我们将深入探讨Servlet的创建、配置和运行过程。 首先,Servlet是一个Java类,它继承自`...
在"java-servlet物流管理-成功.zip"这个压缩包中,我们可以推测它包含了实现一个物流管理系统的相关代码和资源。下面将详细探讨Java Servlet在物流管理中的应用及其相关知识点。 1. **Java Servlet基础** Java ...
"plupload-java-servlet-master.zip"是一个包含Java实现的plupload上传组件的源代码库,为开发者提供了高效、稳定的文件上传解决方案。本文将深入探讨plupload的原理,JavaServlet的运用,以及如何在毕业设计项目中...
这个"Java-Servlet-API.zip"文件很可能包含了Servlet API的离线帮助文档,例如Servlet-API.chm文件,这通常是一个HTML帮助文档,用于开发者查阅API接口和类的详细信息。 Servlet API是Java标准版(Java SE)的一...
在给定的"java-servlet-src源码"中,包含了Servlet的源代码,这对于学习和理解Servlet的工作原理以及如何使用它们来构建动态Web应用程序非常有帮助。 javax目录通常包含了Servlet API的核心类和接口,其中包括: 1...
这个API文档,"java-servlet API DOC",包含了详细的类和接口说明,帮助开发者理解并使用这些组件来构建动态、交互式的Web应用。 一、Servlet API概述 Servlet API是由Java.sun.com(现在归Oracle所有)维护的一组...
在Java Servlet领域,"sample-in-java-servlet.rar_in"这个标题可能是指一个示例项目,展示了如何在Servlet中实现一个消息板功能。描述中的"Message box in Java servlet"进一步确认了这一点,它意味着我们将探讨...
【jsp-Java-servlet-jdbcMysql-filter-CRUD】是一个综合性的项目,它涵盖了Java Web开发中的多个重要技术,包括JSP(Java Server Pages)、Servlet、JDBC(Java Database Connectivity)、MySQL数据库以及Filter过滤...
Java Servlet技术是Java Web开发中的核心部分,它用于创建动态Web应用程序。Swagger是一个流行的API文档和测试工具,它使得RESTful API的设计、构建、文档化和测试变得更加简单。本项目结合Swagger与Servlet,旨在...
《基于Java-Servlet的学生成绩管理系统》 Java-Servlet技术是Java Web开发中的核心组件,主要用于处理HTTP请求,构建动态Web应用。在本“学生成绩管理系统”中,Servlet扮演了服务器端的重要角色,实现了数据的存储...
Java-Servlet学生成绩管理系统(原皮)
赠送jar包:sentinel-web-servlet-1.8.0.jar; 赠送原API文档:sentinel-web-servlet-1.8.0-javadoc.jar; 赠送源代码:sentinel-web-servlet-1.8.0-sources.jar; 赠送Maven依赖信息文件:sentinel-web-servlet-...
该项目名为"javafr_PROJET-JAVA-SERVLET-SIMULATION-SITE-ACHAT-_Selling",是一个基于Java Servlet技术构建的简单电子商务网站。它主要用于模拟售卖迈克尔·杰克逊(MJ)的音乐专辑,并允许用户进行评论互动。这个...
【Java-Servlet】拾起海中的漂流瓶
Java-Servlet学生成绩管理系统(带前端样式)
【Java-Servlet】漂流瓶网站可上传文字和图片
赠送jar包:jersey-container-servlet-core-2.22.2.jar; 赠送原API文档:jersey-container-servlet-core-2.22.2-javadoc.jar; 赠送源代码:jersey-container-servlet-core-2.22.2-sources.jar; 赠送Maven依赖信息...
JavaBridge.jar实现了Servlet接口,使得它能在任何支持Servlet的Java应用服务器上运行,如Tomcat、Jetty等。 2. **php-servlet.jar**: php-servlet.jar是PHP/Java Bridge的另一个关键部分,它是一个Servlet,负责...
Java Servlet是Java Web开发中的核心组件之一,它用于构建动态网站和Web应用程序。Servlet是一个Java类,遵循Java Servlet API规范,能够接收并响应来自客户端(如浏览器)的HTTP请求,处理数据,然后返回响应结果。...