I am reteriving the set of values inside a table from database in a jsp page then it is in the form of link. Now I want to click that value and move to another jsp page. How to code the program so that it can recognise that value and it can move to the next desired page. But I unable to do that. please help me....
+1
A:
Well, the steps are something like:
- Query the database (with JDBC for example)
- Iterate the
ResultSet
and add each link to ajava.util.List
- Use an object
Link
that has two fields - the href, and the text value. - This all is invoked from the
doGet()
method of a servlet - when you have theList
, place it in the request usingrequest.setAttribute("links", linksList)
- forward to the JSP (
request.getRequestDispatcher("yourPage.jsp").forward()
; On the page use JSTL to do the following:
<c:forEach items="${links}" var="link"> <a href="${link.href}">${link.text}</a> </c:forEach>
Bozho
2010-05-28 04:55:24