This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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);
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getAttribute from servlet on jsp page load
 
Similar Threads
loading an action class in jsp
Validation Problem
confused between attributes and parameters
jsp page contents..
Data of previous form gets submitted on refersh