Chinaunix首页 | 论坛 | 博客
  • 博客访问: 524196
  • 博文数量: 151
  • 博客积分: 7010
  • 博客等级: 少将
  • 技术积分: 1405
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 14:32
文章分类

全部博文(151)

文章存档

2011年(1)

2010年(23)

2009年(1)

2008年(126)

我的朋友

分类: 系统运维

2008-08-08 11:27:25

一、Accessing Parameter Values with JSTL Actions
    <%@ page contentType="text/html" %>
    <%@ taglib prefix="c" uri="" %>
     
   
     
        User Info Entry Form
     
     
       

         
           
             
             
           
           
             
             
             
           
           
             
             
             
           
             
             
           
           
             
             
             
           
           
             
             
           
           
             
           
         
Name:
               
             
Birth Date:
               
             
(Use format yyyy-mm-dd)
Email Address:
               
             
(Use format >
           
Gender:
                Male

                Female
             
Lucky number:
               
             
(A number between 1 and 100)
Favorite Foods:
                Pizza

                Pasta

                Chinese
             

               
             

       

     
        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:
         
             
         

     
   
阅读(1591) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~