File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes request.getAttribute from servlet on jsp page load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "request.getAttribute from servlet on jsp page load" Watch "request.getAttribute from servlet on jsp page load" New topic
Author

request.getAttribute from servlet on jsp page load

Alex Bagrel
Greenhorn

Joined: Nov 16, 2011
Posts: 2
Hi.
I have a servlet that makes a database query and the results set are passed to a jsp page using the RequestDispatcher, after using request.setAttribute . In the jsp page I can get the data from the servlet using a form action. But I want to display the results from the database on the jsp page load. I have tried to do that by using javascript to auto submit the form on the page load but it's not a good solution. Is there any method to get the data from the servlet on the page load using request.getAttribute and no form action? The results must be on the same jsp page.
Thank you.
Alex Bagrel
Greenhorn

Joined: Nov 16, 2011
Posts: 2
I have managed to do it. Thanks anyway.

ArrayList ar = (ArrayList) request.getAttribute("ar");
if (ar == null) {
getServletContext().getRequestDispatcher("/Query").forward(request, response);
}
 
GeeCON Prague 2014
 
subject: request.getAttribute from servlet on jsp page load