File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes 'A HREF = a row in Database' for each req_id in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark " Watch " New topic
Author

'A HREF = a row in Database' for each req_id in Servlets

Lijoy John
Ranch Hand

Joined: Jul 24, 2001
Posts: 32
Hi ,
I am displaying a table on the browser with 2 columns from a Table called REQUEST in the database using Servlets. Now as the table is displayed with about say 10 rows and 2 columns. I would like to have a hyperlink to each row(ReqId) of the REQUEST table which is actually an XML file when i click on say '001' shown below.
Example:
ReqID Name
---------------------------
001(hyperlink)/ ABC
002(hyperlink)/ xyz
003(hyperlink)/ pqr
When i click on '001' then the data in a particular column called 'request_detail' in the databse should be displayed displayed on the browser.(Now this data in that particular row where req_id is '001' in the database has a column by the name request_detail.
The code in the servlet is :
<TR><TD><A HREF ={MyLink}> 001 </a></td> 'MyLink' should automatically be replaced when say req_id become 004 or 006 with its corresponding data as a link to it.

Kindly let me know how to proceed with this .
Any Help would be appreciated.
Thanks,

Regards,
John
Sunetra Saha
Ranch Hand

Joined: Feb 25, 2001
Posts: 77
If you have stored the value of reqId in some java field - say reqid - you can create a new field reqidLink=someString+reqid and then in later on have
<a href="<%reqidLink%>"><%=reqid%></a>
Though I am not sure if this is what you were asking.
Lijoy John
Ranch Hand

Joined: Jul 24, 2001
Posts: 32
Hi Sunetra,
Thanks for replying to my query. As per your advise i had created a String variable and then used it to get the hyperlink.
Also had an int variable and stored in the value i had retrieved from the database use the getInt()method.
I had used the hyper link in the following way:
sb.append("<TD>"+ req_id + "</TD><TD>" + name + "</TD><TD><a href=/kp/getxmldata?Req_id='"+req_id+"'>" + reqXml + "</a></TD><TD><a href=/kp/getxmldata?Res_id='"+req_id+"'>" + resXml + "</a></TD><TD>" + status + "</TD><TD>" + daate + "</TD>");
Kindly let me know if this would a right approach to go ahead.
Thanks once again.
Regards,
John

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 'A HREF = a row in Database' for each req_id in Servlets