• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Send Parameters from One JSP to Another using Links?

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I have a main jsp page which has seven links! So i want the main page to forward a parameter to another jsp according to the link clicked! I mean each link should send a different parameter value to the second page! Is there anyway we can do that? I read something about html:link but i did not get the exact syntax of it! Could you please tell me how?
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just have static links, then you can directly add parameters to the requested JSP's URL like this



If you want to use the html:link tag (which I think is available in struts), then you can read this...
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But how do i differentiate from them in the next page and retrieve which value came through? They don't have a name (as in a variable name or something)!
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you notice the query string in the links, it is like ?param=value. The param here is the name of the request parameter and value is the value of this parameter. You can use request.getParameter("param") to get this value in your servlet...
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh thanks! I thought param was a fixed name!
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSP can also use EL to read the param value. I.e., target.jsp could use ${param.param} to get the value of the parameter named "param". In your example this would return "value1" through "value7", depending on which link the user clicked on. The syntax is ${param.a}, where "a" is the name of the parameter whose value you want.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Somnath Mallick wrote:Oh thanks! I thought param was a fixed name!


If you are going to be working with web apps, I'd suggest becoming more familiar with HTTP concepts.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Somnath Mallick wrote:Oh thanks! I thought param was a fixed name!


If you are going to be working with web apps, I'd suggest becoming more familiar with HTTP concepts.



Could you please mention some pdf's where i can clear out these out concepts. It would be of great help!
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Google: HTTP Specification
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be some of these links will get clear understanding

http://roseindia.net/jsp/simple-jsp-example/ConditionalForwardUsingEL.shtml

http://roseindia.net/jsp/simple-jsp-example/RequestParametersInEL.shtml
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic