I have a servlet which makes a database query. Now I need to forward the final resultset to my jsp page and then display the rows using display-tag. How to do this? How to transfer the resultset from servlet to jsp. Can’t forward resultset directly as it is not serializable.
What if I have to transfer two resultsets from servelet to jsp?
An object doesn’t have to be serializable to be stored in a request attribute. The HttpServletRequest object and its attributes live in memory.
And displaytag uses a collection (a List, most of the time) of objects which should respect JavaBeans conventions.
So the process is simple:
List<Foo>containing the data retrived by the queryrequest.setAttribute("foos", fooList);${foos}as a table.If you have to transfer two resultsets, execute 2 requests, build two lists, store them in 2 request attributes, and use the displaytag twice in the JSP.