JSP Servlet shared bean example
Jump to navigation
Jump to search
Servlet code:
public void doRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ HttpSession session = req.getSession(); FooBean foo= new FooBean ; foo.setName("FooBean", "bar"); session.setAttribute("FooBean", foo);
JSP code
<jsp:useBean id="foo" type="FooBean" scope="session"/> <jsp:getProperty name="foo" property="name"/>