Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing values to JSp with href

 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 jsp�s (First.jsp, second.jsp).
I have one a:href on First.jsp where it goes to Second.jsp , and also it needs to take some ID values from First.jsp to Second.jsp.

Below is my code (First.jsp):
<h:inputHidden id =�employeeId� value = �#{employee.employeeID}�
<h:inputHidden id =�applicationId� value = �#{employee.appliationID}�
Below iy my href:
<a href = �/jsp/Second.jsp� > Add Application </a>

How can I send values of employeeId and applicationID to Second.jsp , on clicking Add Application on first.jsp
Any suggestions
Thanks..
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Gosh:

<h:inputHidden id =�employeeId� value = �#{employee.employeeID}�
<h:inputHidden id =�applicationId� value = �#{employee.appliationID}�


These aren't standard HTML or JSP tags.
What framework/library are you using?
 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am Using JSF
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,

You can either submit the form with the 2 fields to your second.jsp or call a javascript function onClick of your anchor link, add fields as querystring and then pass the queryString to your second.jsp. Your second jsp will get the values as request parameters.
[ August 17, 2007: Message edited by: Shailesh Kini ]
 
Ronald Aguilar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can still used the standard foward and redirect
 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx for suggestions Shailesh..

Do you have any code for example ..

Thanks
 
Denise Smith
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using an IDE? If so which one??
 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elipse 3.1
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use this.

 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sushma for the sample. If I pass appId, how can I print this appId on the next screen.


Thanks,
Rahul
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can get the values of parameter like this


where employeeId is the name of the parameter.
 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the scope of your employee bean? If it is in session scope, the employeeId and appId are automatically available in your second jsp. You can refer these properties in the same way as you referred them in your first jsp.
 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using request scope. Thannks for your tip to keep in session scope.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic