How can I send a an object got it from a bean in a JSP page to a Servlet after clicking an hyperlink??
something like…
...
<td align="center"><% if(j.getClubActual().isIsResource()){ request.setAttribute("equipo", j.getClubActual());%>
<a href="teamServlet" type="submit" target="_blank"><%= j.getClubActual().getNombre()%></a><%}%>
</td>
...
But when I try to recover it in the teamServlet, the request object is empty.
Thanks in advance.
The lifetime of a HTTP request ends when its associated HTTP response is finished sending the data (read: the HTML page generated by JSP). Clicking a link will create a brand new HTTP request which doesn’t contain the attributes of any previous request at all.
You need to send the unique identifier of the Java object in question as a request parameter. Ultimately, the HTML must end up to basically look like this:
In the servlet, you can get the request parameter as follows:
You can use this value to re-obtain the Java object associated with the given ID from some data store.