I have a
jsp page that has an html from that does a post to a
servlet. The servlet then takes the data and puts it into a bean and then send it to another jsp page. I was using the following code:
Servlet:
getServletContext().setAttribute("logonBean", logonBean);
response.setIntHeader("Refresh", 0);
response.sendRedirect(pageName);
JSP:
<jsp:useBean id="logonBean" class="logon.LogonBean" scope="application" />
This was working but I read in this forum that using servletContext could cause problems if I have more than one user at a time so I decided to use HttpSession and changed my code to this:
Servlet:
HttpSession session = request.getSession(true);
session.setAttribute("logonBean", logonBean);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(pageName);
dispatcher.forward(request, response);
JSP:
<%@ page session="true" %>
<jsp:useBean id="logonBean" scope="session" class="logon.LogonBean" />
The problem is that it doesn't work now. If I use the requestDispatcher instead of redirect all I get in the browser is a page not found with the servlet as the url. If I go back to using the redirect the jsp page blows up from apparently not being able to read the bean. Does anyone see anything obvious that I am doing wrong or give me suggestions to try.