Obtain URL request parameters on the JSP page

Source: Internet
Author: User
Tags tld
    1. JSP page

When using the jstl's Expression Language, the request parameters are made available in the implicit objectParam. This example demonstrates how to include the value of a request parameter from the query string or posted data in the generated output:

 
When jstl is used, the URL request parameters are placed in the hidden object.ParamThe following example shows how to obtain request parameters from a URL.
<% -- Declare the core library -- %> <% @ taglib uri = "/WEB-INF/TLD/C. TLD "prefix =" C "%> <C: Choose> <C: When test =" $ {emptyParam. Name} "> Please enter your name. </C: When> <C: otherwise> Hello <B> <C: Out value ="$ {Param. name}"/> </B>! </C: otherwise> </C: Choose>

When the following URL is used to request a page

 
Http://hostname.com/mywebapp/mypage.jsp? Name = John + Smith

Page display:

 
Hello <B> john smith </B>!
 
For Request ParametersNameUse<C: Out value = "$ {Param. name}"/>Output
 
 
In addition, if the request parameters contain spaces, separate them with +.
 
 
  
  
  1. Use of the sturts framework

When using action-type forwarding, you can call request. getparameter ("name") in the action class to obtain the request parameters,

When the request is forwarded to the target page, the request parameter still exists in the request, so the target page can still retrieve the request parameter through the param object;

This method also applies when forwarding directly to the page only through forwardaction.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.