一、Accessing Parameter Values with JSTL Actions
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="" %>
User Info Entry Form You entered:
Name:
Birth Date:
Email Address:
Gender:
Lucky Number:
Favorite Food:
All form field values except the Favorite foods checkbox values are added using a JSTL
action with an EL expression that retrieves the request parameter value,for instance :
Name:
When a user checks off mutiple checkboxex that share the same name, the request contains mutiple parameters whith the same name.If none is checked, the request doesn't contain the corresponding parameter at all.To display the choices the user made,we need to get all parameter values and a way to deal with them one at a time.The implicit paramValues variable and the JSTL
action satisfy these requirements.
二、Accessing Other Request Data
There's a lot of information passed with a request besides the parameters.Header values can be accessed through the 'header' and 'headerValues' variables,and cookies through the 'cookie' variable. for example:
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="" %>
Request Info
The following information was received:
- Request Method:
- Request Protocol:
- Context Path:
- Servlet Path:
- Request URI:
- Request URL:
- Server Name:
- Server Port:
- Remote Address:
- Remote Host:
- Secure:
- Cookies:
:
- Headers:
:
三、Capturing Parameter Values Using a Bean
...
class="com.ora.jsp.beans.userinfo.UserInfoBean">
You entered:
Name:
Birth Date:
Email Address:
Gender:
Lucky Number:
Favorite Food: