Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getAttribute from servlet on jsp page load

 
Alex Bagrel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have managed to do it. Thanks anyway.

ArrayList ar = (ArrayList) request.getAttribute("ar");
if (ar == null) {
getServletContext().getRequestDispatcher("/Query").forward(request, response);
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic