Please help how to pass a JavaBean from servlet to jsp?

Hi there,

I have got a dispatch servlet and I want the dispatch servlet to get the data and store it in a JavaBean before dispatching to the appropriate JSP page. However, I don't know how to pass the javabean to the JSP when the servlet forward the request to the JSP. Is ServletContext.setAttribute() the only way to pass the javabean to the JSP page?

Thank you very much!

Edmund

[414 byte] By [yu_hung] at [2007-9-26 3:03:45]
# 1
You can use HttpServletRequest.setAttribute(String name, Object javabean) to set the javabean into the HTTP request that you are forwarding to the JSP.In the JSP, you can access the Javabean using request.getAttribute(String name) and cast it to the right class.
neville_sequeira at 2007-6-29 11:04:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...