Java 应用与开发 - Servlet 编程Web 容器 内,由 Web 容器负责它的对象的创建和销毁,不能直接由 其它类对象来调用。 ▶ 当 Web 容器接收到对它的 HTTP 请求时,自动创建 Servlet 对象,并自动调用它的 doPost 或 doGet 方法。 Servlet 的主要功能 ▶ 接收用户 HTTP 请求。 ▶ 取得 HTTP 请求提交的数据。 ▶ 调用 JavaBean 对象的方法。 ▶ 生成 HTML Servlet 概述 Servlet 编程 Servlet 生命周期 Servlet 配置 Servlet 部署 Servlet 示例 重写 doPost 方法 编写 Servlet 需要重写父类的 doPost 方法。 1 public void doPost(HttpServletRequest request, HttpServletResponse response) 2 throws ServletException ServletException, IOException { 3 // Rewrite the method. 4 } 当请求方式为 POST 时自动运行,每次请求都运行一次。 doGet 和 doPost 方法都接收 Web 容器自动创建的请求对象和 响应对象,使得 Servlet 能够解析请求数据和发送响应给客户端。 大纲 Web 基础 Servlet 概述 Servlet 编程 Servlet0 码力 | 50 页 | 725.36 KB | 1 年前3
《Java 应用与开发》课程讲义 - 王晓东214 16.3.3 重写 doGet 方法 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 16.3.4 重写 doPost 方法 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 16.3.5 重写 init 方法 . . . . . . Web 容器内,由 Web 容器负责它 的对象的创建和销毁,不能直接由其它类对象来调用。 • 当 Web 容器接收到对它的 HTTP 请求时,自动创建 Servlet 对象,并自动调用它 的 doPost 或 doGet 方法。 Servlet 的主要功能 • 接收用户 HTTP 请求。 • 取得 HTTP 请求提交的数据。 • 调用 JavaBean 对象的方法。 • 生成 HTML Rewrite the method. 5 } 当 HTTP 请求为 GET 时自动运行,每次请求都运行一次。 16.3.4 重写 doPost 方法 编写 Servlet 需要重写父类的 doPost 方法。 1 public void doPost(HttpServletRequest request, HttpServletResponse response) 2 throws ServletException0 码力 | 330 页 | 6.54 MB | 1 年前3
Reference guide for FCL units. Document version 3.2.2TEZcgi.GetValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 15.5.10 TEZcgi.DoPost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 15.5.11 TEZcgi.DoGet . . supported by this component. To use the unit, a descendent of the TEZCGI class should be created and the DoPost (540) or DoGet (540) methods should be overridden. 15.3 Constants, types and variables 15.3.1 Constants Programs wishing to use this class should make a descendent class of this class and override the DoPost (540) or DoGet (540) methods. To run the program, an instance of this class must be created, and0 码力 | 953 页 | 2.21 MB | 1 年前3
跟我学Shiro - 张开涛getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Shiro——http://jinnianshilongnian.iteye.com/ 68 1、doGet 请求时展示登录页面; 2、doPost 时进行登录,登录时收集 username/password 参数,然后提交给 Subject 进行登录。 如果有错误再返回到登录页面;否则跳转到登录成功页面(此处应该返回到访问登录页面 之前的 HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException0 码力 | 219 页 | 4.16 MB | 10 月前3
servlet mechanismservice() doGet() doPost() Get Request Post Request Response Response Web Server HttpServlet subclass 注意: 方法由 HttpServlet 的子类实现0 码力 | 1 页 | 16.55 KB | 1 年前3
Java EE 企业应用系统设计 - HTTP 请求处理编程请求对象生命周期 在 Java Web 组件开发中,不需要 Servlet 或 JSP 自己创建请求 对象,它们由Web 容器自动创建,并传递给 Servlet 和 JSP 的 服务方法 doGet 和 doPost,在服务处理方法中直接使用请求对 象即可。 大纲 HTTP 请求内容 Java EE 请求对象 请求对象类型与生命周期 O 请求对象创建 每次 Web 服务器接收到 HTTP 请求时,会自动创建实现0 码力 | 27 页 | 565.27 KB | 1 年前3
Java EE 企业应用系统开发 - HTTP 响应处理编程响应的内容 HTTP 响应对象 响应对象功能和方法 响应对象生命周期 1. Web 容器自动为每次 Web 组件的请求生成一个响应对象。 2. Web 容器创建响应对象后,传入到 doGet 或 doPost 方法。 3. 通过响应对象向浏览器发响应。 4. 响应结束后,Web 容器销毁响应对象,释放所占用的内存。 大纲 HTTP 响应的内容 HTTP 响应对象 响应对象功能和方法 接下来⋯0 码力 | 26 页 | 575.28 KB | 1 年前3
Java 应用系统开发 - ServletContext 和 Web 配置this.config = config; 6 } 1. 要取得 ServletConfig 对象需要重写 init 方法,并传递 ServletConfig 参数。然后在 doGet 和 doPost 方法中即可以 使用 config 对象。 2. 与 ServletContext 和 HttpSession 对象不同,Web 容器为 每个 Servlet 实例创建一个 ServletConfig0 码力 | 33 页 | 668.91 KB | 1 年前3
Java 应用与开发 - JSP (Java Server Page)服务器接收到请求,如果没有此地址,发出错误响应给 浏览器; 3. Web 服务器检查 JSP 文件和对应的 Servlet 版本的时间是 否一致,如果一致则执行 servlet 的处理请求方法,类似于 doGet 或 doPost,发送响应给浏览器; 4. 版本时间不一致,Web 服务器调用转换系统,将 JSP 的文 本代码转换为 Servlet 的 Java 代码; 5. 将 Java 代码编译为 class 文件;0 码力 | 47 页 | 740.36 KB | 1 年前3
Java 应用与开发 - MVC 和框架初步本节习题 Servlet 方式 1 public class LoginServlet extends HttpServlet { 3 @Override 4 protected void doPost(HttpServletRequest req, HttpServletResponse resp) 5 throws ServletException, IOException { 6 String0 码力 | 51 页 | 837.26 KB | 1 年前3
共 14 条
- 1
- 2













