request对象的类型为HttpServletRequest。在JSP翻译成的Java类中,有这样的函数:
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException
当客户请求到达服务器时,该函数将被调用。该函数负责生成并输出客户请求的html代码。
HttpServletRequest是一个接口,扩展自ServletRequest接口。该接口提供了一系列方法,主要用于http服务器了解客户端的请求。下面的例子演示了如何获取位于表单中的编辑框中的用户输入数据。
第一个页面让用户输入:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import= "java.io.*"%>
<%@page import= "huangxiaoxing.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<