//styleDetail.jsp
<html>
<jsp:useBean id="productView" scope="request" class="com.view.ProductView" />
....
<% List result = productView.getProductList();
Iterator it = result.iterator();
while(it.hasNext()){ %>
<tr>
<td><input type="checkbox" name="id"></td>
<% List temp = (List) it.next();
Iterator it1 = temp.iterator();
while(it1.hasNext()) {
Object obj = it1.next();
request.getSession().setAttribute("value",obj); %>
<td><a href="ProductController?selectedValue=link">
<% out.print(obj); %>
</a></td><% } %>
</tr><% } %>
.....
</html>
//ProductController.java
....
String selectedValue = request.getParameter("selectedValue");
if(selectedValue!=null)
{
if(selectedValue.equals("link"))
{
Object obj = request.getSession().getAttribute("value");
System.out.println(obj);
response.sendRedirect("productResult.jsp");
}
}
...
When i run the above code, a table is displayed with links. when i click on the link, the control is passed to the servlet 'ProductController' and i want to get the value of the link i have clicked.... If suppose the link clicked is 'ABC', this value should be read in the servlet..When i run the above code, the value of 'obj' is printed as 4 irrespective of any link i click in the jsp. Kindly help with a solution.....