Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get objects from an included

 
Donna Reschke
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jsp that needs objects wich are generated in a servlet.
i need to include this servlet in the jsp and need to be able to get objects from the
servlet.
how can this be done?
 
Bhupinder Dhillon
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You set the objects as attributes in the HttpServletRequest object and access them in the JSP.
//servlet code
request.setAttribute("objectName", new Object());
//jsp code
Object obj = request.getAttribute("objectName");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic