getting a Javabean with request scope in a servlet
Posted on 2003-03-18
I have a JavaBean (A REQUEST SCOPE ONE!!) as an attribute to be attached to my HttpRequest.
In servlet enviroment all does work fine with:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Servlet1");
but if i forward it from a jsp page (trying to attached to the request as an attribute) to a servlet invocated by a submit form as in the following:
<jsp:useBean id="login" class="LoginBean" scope="request"/>
<form name="form" action="Servlet2" method="post">
<input name="submit" type="submit" value="submit">
and i do in Servlet2:
LoginBean bean = (LoginBean) request.getAttribute("login");
it raises me a NullPointerException as if the bean is not retrieved.
Has the request already expired?
I tried also in jsp the following:
request.setAttribute("login", loginBean); %>
If so, am i forced to use a session-scope-Javabean?
for my application is compulsory having a request scope
Any suggestions would be highly appreciated!
Please help me!