I'm trying to figure out how to get results from a database query to be displayed on a listed page and if the user wants to know more about the results they will click one of the dynamically generated items that is hyperlinked. This will then bring the user to a detail page where they can read more about the item.

Currently, I have used one of the JSTL objects to connect to my SQL Server database and produce the correct results into a data table onto the item listing page. However I'm not quite clear on how to make these results be hyperlinks that query the detail page.

I've done this hundreds of times in ASP.NET but to be honest I haven't the slightest clue on how to do this in JSP. Any pointers or references to tutorials would be much appreciated.

Recommended Answers

All 2 Replies

Let's say you retrieved some books' name/title from the database and you want to print their name/title on the page, and still be a link.
You'll have to write something like this:

<a href=GetBook.jsp?book=<%= BookTitle[i]%> > <%=BookTitle[i]%> </a>

Hope that answers your question. If not, tell me, i can try to help you further.

thanks for your help. Your suggestion was helpful. I ended up using a slight variation since I'm using the JSTL data table

<h:outputLink value="ListingTerm.faces?term=#{vartermListing.NAME}">
   <h:outputText id="termName" value="#{vartermListing.NAME}" styleClass="outputText">
   </h:outputText>											</h:outputLink>
commented: Nice to see someone using JSTL after all +21
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.