分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

servlet/jsp随记

发布时间:2023-09-06 02:02责任编辑:顾先生关键词:jsjsp

Servlet接口

public interface Servlet { ???...... ???public void init(ServletConfig config) throws ServletException; ???public ServletConfig getServletConfig(); ???public void service(ServletRequest req, ServletResponse res) ???????????throws ServletException, IOException; ???public String getServletInfo(); ???public void destroy(); ???......}
View Code

RequestDispatcher接口

public interface RequestDispatcher { ???...... ??/** ????* Forwards a request from ????* a servlet to another resource (servlet, JSP file, or ????* HTML file) on the server. This method allows ????* one servlet to do preliminary processing of ????* a request and another resource to generate ????* the response. ????* ????* <p>For a <code>RequestDispatcher</code> obtained via ?????* <code>getRequestDispatcher()</code>, the <code>ServletRequest</code> ?????* object has its path elements and parameters adjusted to match ????* the path of the target resource. ????* ????* <p><code>forward</code> should be called before the response has been ?????* committed to the client (before response body output has been flushed). ?????* If the response already has been committed, this method throws ????* an <code>IllegalStateException</code>. ????* Uncommitted output in the response buffer is automatically cleared ?????* before the forward. ????* ????* <p>The request and response parameters must be either the same ????* objects as were passed to the calling servlet‘s service method or be ????* subclasses of the {@link ServletRequestWrapper} or ????* {@link ServletResponseWrapper} classes ????* that wrap them. ????* ????* <p>This method sets the dispatcher type of the given request to ????* <code>DispatcherType.FORWARD</code>. ????* ????* @param request a {@link ServletRequest} object that represents the ????* request the client makes of the servlet ????* ????* @param response a {@link ServletResponse} object that represents ????* the response the servlet returns to the client ????* ????* @throws ServletException if the target resource throws this exception ????* ????* @throws IOException if the target resource throws this exception ????* ????* @throws IllegalStateException if the response was already committed ????* ????* @see ServletRequest#getDispatcherType ????*/ ???public void forward(ServletRequest request, ServletResponse response) ???????throws ServletException, IOException; ???/** ????* ????* Includes the content of a resource (servlet, JSP page, ????* HTML file) in the response. In essence, this method enables ?????* programmatic server-side includes. ????* ????* <p>The {@link ServletResponse} object has its path elements ????* and parameters remain unchanged from the caller‘s. The included ????* servlet cannot change the response status code or set headers; ????* any attempt to make a change is ignored. ????* ????* <p>The request and response parameters must be either the same ????* objects as were passed to the calling servlet‘s service method or be ????* subclasses of the {@link ServletRequestWrapper} or ????* {@link ServletResponseWrapper} classes that wrap them. ????* ????* <p>This method sets the dispatcher type of the given request to ????* <code>DispatcherType.INCLUDE</code>. ????* ????* @param request a {@link ServletRequest} object that contains the ????* client‘s request ????* ????* @param response a {@link ServletResponse} object that contains the ????* servlet‘s response ????* ????* @throws ServletException if the included resource throws this ????* exception ????* ????* @throws IOException if the included resource throws this exception ????* ????* @see ServletRequest#getDispatcherType ????*/ ???public void include(ServletRequest request, ServletResponse response) ???????throws ServletException, IOException; ???......}
View Code

JSP内置的对象

- request:封装客户端的请求,其中包含来自GET或POST请求的参数; - response:封装服务器对客户端的响应; - pageContext:通过该对象可以获取其他对象; - session:封装用户会话的对象; - application:封装服务器运行环境的对象; - out:输出服务器响应的输出流对象; - config:Web应用的配置对象; - page:JSP页面本身(相当于Java程序中的this); - exception:封装页面抛出异常的对象
View Code

servlet/jsp随记

原文地址:https://www.cnblogs.com/suheng/p/9245415.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved