Can I use a request.setAttribute for a form?
843835Jan 24 2002 — edited Jan 25 2002Hi All,
I have a jsp1.jsp page that is basically a form, having HTML input text, etc. I am trying to set an attribute on this form and trying to get it back on another jsp2.jsp page using request.getAttribute.
When I try, I get the following error generated by jsp2.jsp
java.lang.NullPointerException
I've created anotheer jsp3.jsp page, used setAttribute and use the command
<jsp:forward page = "jsp2.jsp" />
jsp2.jsp then works perfect.
It appears that we cannot set attributes in a form. Is it true.
Note: I have several other jsp pages being forward to jsp2.jsp, and jsp1.jsp is the only page where the user enters data, so I cannot use hidden parameters for the other pages.
******
on jsp1.jsp I have
<%
request.setAttribute("asAction", "Deliver");
%>
and
<form action = "jsp2.jsp" method = "post">
*****
on jsp2.jsp I've tried
<%
String sAction = (String)request.getAttribute("asAction");
%>
and the error comes up.
Thanks in advance for any help
Regards,
Trajano Roberto