How to send parameters or value to one JSP to another


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to send parameters or value to one JSP to another

  1. #1
    Varma Guest

    How to send parameters or value to one JSP to another


    Larry,
    What are the ways to send parameter values from one plain jsp page(no
    html inside in it) to another jsp.
    I know one way is through session variables.

    Thanks
    Varma
    Share on Google+

  2. #2
    Larne Pekowsky Guest

    Re: How to send parameters or value to one JSP to another

    Varma <vbhupatiraju@business.com> wrote:
    > What are the ways to send parameter values from one plain jsp page(no
    >html inside in it) to another jsp.
    >I know one way is through session variables.


    Hi Varma,

    There are a few possibilities, depending on what exactly you need to
    do.

    If the first page is going to automatically invoke the second, you can
    use a jsp:include or jsp:forward, and pass the values with one or more
    jsparam tags. This would look something like:

    <jsp:forward page="secondpage.jsp">
    <jsparam name="parameter1_name" value="parameter1_value">
    <jsparam name="parameter2_name" value="parameter2_value">
    ...
    </jsp:forward>

    paramater1_value could be a simple expression, or a value of the form
    <%= something %>.

    If the first page requires the user to click a form submit button, the
    values can be passed as hidden fields, which would look like this:

    <form action="secondpage.jsp" method="POST">
    <input type="hidden" name="parameter1_name" value="parameter1_value">
    <input type="hidden" name="parameter2_name" value="parameter2_value">
    ...
    <input type="submit">
    </form>

    Again, the parameter values can be <%= %> expressions.


    If the page requires the user to click an href before proceeding, you
    can pass the parameters in a query string, as in:

    <a href="secondpage.jsp?paramater1_name=parameter1_value&paramater2_name=parameter2_value&... ">

    Again, you can use <%= %> tags for the values, but there are some
    things to watch for. If the result of the <%= %> is going to contain
    any of the characters %, &, = or / you might need to urlencode the
    values before they can be used. In this case, it would probably be
    easer to use some session variable, as you noted.

    - Larne

    Share on Google+

Similar Threads

  1. Handling XMLHttp request in JSP
    By jijesh in forum Java
    Replies: 0
    Last Post: 07-19-2005, 08:55 AM
  2. How to send multiple parameters into a popup?
    By liliarum in forum ASP.NET
    Replies: 1
    Last Post: 06-14-2005, 04:07 PM
  3. Replies: 0
    Last Post: 04-07-2005, 03:40 AM
  4. How to invoke C DLLs from a JSP
    By Mohan in forum Java
    Replies: 6
    Last Post: 03-02-2001, 02:42 PM
  5. JSP and the <SERVLET> tag
    By Dusty in forum Java
    Replies: 2
    Last Post: 04-07-2000, 01:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center