This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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: 482
  • 0
  • Mark post as helpful
  • send pies
  • 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: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thanks! I thought param was a fixed name!
 
Max Rahder
Ranch Hand
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64184
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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: 482
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64184
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google: HTTP Specification
 
ahalya priya
Greenhorn
Posts: 10
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic