File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to Send Parameters from One JSP to Another using Links? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to Send Parameters from One JSP to Another using Links?" Watch "How to Send Parameters from One JSP to Another using Links?" New topic
Author

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

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Aug 03, 2008
Posts: 9302
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Aug 03, 2008
Posts: 9302
    
  17

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

Joined: Mar 04, 2009
Posts: 477
Oh thanks! I thought param was a fixed name!
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
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

Joined: Jan 10, 2002
Posts: 61221
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Jan 10, 2002
Posts: 61221
    
  66

Google: HTTP Specification
ahalya priya
Greenhorn

Joined: Jan 21, 2009
Posts: 10
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Send Parameters from One JSP to Another using Links?