Java 应用与开发 - Servlet 编程内,由 Web 容器负责它的对象的创建和销毁,不能直接由 其它类对象来调用。 ▶ 当 Web 容器接收到对它的 HTTP 请求时,自动创建 Servlet 对象,并自动调用它的 doPost 或 doGet 方法。 Servlet 的主要功能 ▶ 接收用户 HTTP 请求。 ▶ 取得 HTTP 请求提交的数据。 ▶ 调用 JavaBean 对象的方法。 ▶ 生成 HTML 类型或非 HTML Servlet 编程 Servlet 生命周期 Servlet 配置 Servlet 部署 Servlet 示例 重写 doGet 方法 父类 HttpServlet 的 doGet 方法是空的,没有实现任何代码,子 类需要重写此方法。 2 public void doGet(HttpServletRequest request, HttpServletResponse response) 3 throws ServletException, IOException { 3 // Rewrite the method. 4 } 当请求方式为 POST 时自动运行,每次请求都运行一次。 doGet 和 doPost 方法都接收 Web 容器自动创建的请求对象和 响应对象,使得 Servlet 能够解析请求数据和发送响应给客户端。 大纲 Web 基础 Servlet 概述 Servlet 编程0 码力 | 50 页 | 725.36 KB | 1 年前3
《Java 应用与开发》课程讲义 - 王晓东213 16.3.2 类定义 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 16.3.3 重写 doGet 方法 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 16.3.4 重写 doPost 方法 . . . . . . Web 容器负责它 的对象的创建和销毁,不能直接由其它类对象来调用。 • 当 Web 容器接收到对它的 HTTP 请求时,自动创建 Servlet 对象,并自动调用它 的 doPost 或 doGet 方法。 Servlet 的主要功能 • 接收用户 HTTP 请求。 • 取得 HTTP 请求提交的数据。 • 调用 JavaBean 对象的方法。 • 生成 HTML 类型或非 HTML LoginAction extends HttpServlet { 2 // Code goes on. 3 } 16.3.3 重写 doGet 方法 父类 HttpServlet 的 doGet 方法是空的,没有实现任何代码,子类需要重写此方法。 2 public void doGet(HttpServletRequest request, HttpServletResponse response) 30 码力 | 330 页 | 6.54 MB | 1 年前3
跟我学Shiro - 张开涛urlPatterns = "/login") public class LoginServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 跟我学 Shiro——http://jinnianshilongnian.iteye.com/ 68 1、doGet 请求时展示登录页面; 2、doPost 时进行登录,登录时收集 username/password 参数,然后提交给 Subject 进行登录。 如果有错误再返回到登录页面;否则跳转到登录成功页面(此处应该返回到访问登录页面 "/formfilterlogin") public class FormFilterLoginServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {0 码力 | 219 页 | 4.16 MB | 10 月前3
Java 应用与开发 - JSP (Java Server Page)服务器接收到请求,如果没有此地址,发出错误响应给 浏览器; 3. Web 服务器检查 JSP 文件和对应的 Servlet 版本的时间是 否一致,如果一致则执行 servlet 的处理请求方法,类似于 doGet 或 doPost,发送响应给浏览器; 4. 版本时间不一致,Web 服务器调用转换系统,将 JSP 的文 本代码转换为 Servlet 的 Java 代码; 5. 将 Java 代码编译为 class 3 % > ▶ 可以同时嵌入多个脚本代码段,但它们都表示在一个方法 内,属于一个代码段,一个脚本内定义的变量,另一个脚本 也可以使用。 ▶ 在代码脚本中定义的变量类似于 Servlet 的 doGet 方法中的 局部变量,未初始化使用是非法的。 例如,连接数据库的代码脚本片段如下: 1 <% 2 Connection cn = null; 3 try { 4 Class.forName("sun0 码力 | 47 页 | 740.36 KB | 1 年前3
Reference guide for FCL units. Document version 3.2.2TEZcgi.DoPost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 15.5.11 TEZcgi.DoGet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540 15.5.12 TEZcgi.Values . . 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 hexTable (540) or DoGet (540) methods. To run the program, an instance of this class must be created, and it’s Run (539) method should be invoked. This will analyze the environment and call the DoPost or DoGet method0 码力 | 953 页 | 2.21 MB | 1 年前3
Spring Framework 1.1.5 ChangelogDispatcherServlet does not override "doHead" anymore, leveraging HttpServlet's default "HEAD" handling via "doGet" * factored out protected "resolveViewName" method from DispatcherServlet's "render" implementation not start with the application's context path (rather unusual) * fixed FrameworkServlet to use "doGet"/"doPost"/"doHead" etc, to reenable proper LastModified support in controllers * fixed DispatcherServlet's0 码力 | 57 页 | 166.71 KB | 1 年前3
Spring Framework 1.2.0 ChangelogDispatcherServlet does not override "doHead" anymore, leveraging HttpServlet's default "HEAD" handling via "doGet" * factored out protected "resolveViewName" method from DispatcherServlet's "render" implementation not start with the application's context path (rather unusual) * fixed FrameworkServlet to use "doGet"/"doPost"/"doHead" etc, to reenable proper LastModified support in controllers * fixed DispatcherServlet's0 码力 | 67 页 | 194.16 KB | 1 年前3
Spring Framework 1.2.2 ChangelogDispatcherServlet does not override "doHead" anymore, leveraging HttpServlet's default "HEAD" handling via "doGet" * factored out protected "resolveViewName" method from DispatcherServlet's "render" implementation not start with the application's context path (rather unusual) * fixed FrameworkServlet to use "doGet"/"doPost"/"doHead" etc, to reenable proper LastModified support in controllers * fixed DispatcherServlet's0 码力 | 72 页 | 205.76 KB | 1 年前3
Spring Framework 1.2.1 ChangelogDispatcherServlet does not override "doHead" anymore, leveraging HttpServlet's default "HEAD" handling via "doGet" * factored out protected "resolveViewName" method from DispatcherServlet's "render" implementation not start with the application's context path (rather unusual) * fixed FrameworkServlet to use "doGet"/"doPost"/"doHead" etc, to reenable proper LastModified support in controllers * fixed DispatcherServlet's0 码力 | 69 页 | 197.87 KB | 1 年前3
Spring Framework 1.2.3 ChangelogDispatcherServlet does not override "doHead" anymore, leveraging HttpServlet's default "HEAD" handling via "doGet" * factored out protected "resolveViewName" method from DispatcherServlet's "render" implementation not start with the application's context path (rather unusual) * fixed FrameworkServlet to use "doGet"/"doPost"/"doHead" etc, to reenable proper LastModified support in controllers * fixed DispatcherServlet's0 码力 | 74 页 | 215.40 KB | 1 年前3
共 26 条
- 1
- 2
- 3













