It's not a secret anymore!
The moose likes JSP and the fly likes Pass values using href in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Pass values using href in JSP" Watch "Pass values using href in JSP" New topic

Pass values using href in JSP

Mehak Daani

Joined: Oct 08, 2003
Posts: 16
I have this code where my callid is a hyper link ..... to another jsp ..... the values of the callid comes from the database .... like calls.getInt("callid)"; ...................
Now my quest is that suppose there are 5 callid ... like 1 2 3 4 5 ... when i click on the 5th callid ... i want the hyperlink to pass the value 5 to another jsp ... where i'll be executing a query based on the 5th callid .... ...
So i have 2 questions:
1. How do i pass the dynamic value through hyper link ...
2. How do i retreive that value in another Jsp.
Please help me out on this one...!!!
Currently my code for the callid looks like this:
<td width="8%"><a href="somepage.jsp"><%=calls.getInt("callid")%></a></font>

Kevin Jones
Ranch Hand

Joined: Oct 29, 2003
Posts: 39
In the first JSP use
<td width="8%"><a href="somepage.jsp?id=<%=calls.getInt("callid")%>"><%=calls.getInt("callid")%></a></font>
this should give you
<a href="http://someserver/somepage.jsp?id=5>5</a>
then in somepage.jsp use
<% request.getParamater("id"); %>

Kevin Jones<br />Author: <a href="" target="_blank" rel="nofollow">Servlets and JSP: The J2EE Web Tier</a>
Mehak Daani

Joined: Oct 08, 2003
Posts: 16
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63211

Welcome to the Ranch Mehak!
As you have seen, you'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
JSP Forum Bartender

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Pass values using href in JSP
It's not a secret anymore!