/servlet-interest Paula Lumby wrote:
>
> The callPage method of the .91 JSP spec did a fine job of calling a JSP from a
> servlet. Is there an example anywhere of doing the same thing with the JSP 1.0
> reference implementation. In particular, how to do you pass a bean or session
> object to the JSP?

The callPage method is replaced with the RequestDispatcher in JSDK 2.1, i.e.
the base for JSP 1.0. JSDK 2.1 also introduces HttpServletRequest attributes.

So to pass a Bean from a servlet to a JSP page you can,

  req.setAttribute("myBean", myBean);
  RequestDispatcher rd = getServletContext().getRequestDispatcher("/my.jsp");
  rd.forward(req, res);

In your JSP page the Bean is then available as a request scope Bean. If
you like it to be a session scope Bean, just let the servlet put it in
the session instead of setting it as a request attribute.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to