Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Objects return null pointer exception after form action getRequestURI()

7 views
Skip to first unread message

jennifer johnson

unread,
Apr 5, 2004, 12:12:45 PM4/5/04
to
Hello All,

I appreciate anyone's assistance. I wanted to validate user customizable
field values so I changed my JSP page so that the form action would post
existing form - action=<%= getRequestURI() %>. Upon form loading after
submit verify field values and if any are left empty a message would be
posted, and again form would be reposted until all field values were
confirmed not to be empty. If field values were not left blank then it would
automatically call a servlet to store the field values entered. The jsp page
and form worked perfectly until I tried to implement the field validation.
What happens is any object that I attempt to initialize after the form is
loaded for the second time (after action=<%= getRequestURI() %>) results in
a null pointer exception.

For instance the following works perfectly the first time around, but on the
2nd pass the second line of code draws a null pointer exception.
UserSelections us =
(UserSelections)request.getAttribute(PropertyConstants.USER_SELECTIONS);
int selectedModelId = us.getModelId();

Any help would be greatful,
Mike

Ryan Stewart

unread,
Apr 5, 2004, 1:39:41 PM4/5/04
to
"jennifer johnson" <mjwes...@verizon.net> wrote in message
news:1Afcc.14324$W57....@nwrdny03.gnilink.net...
From the jumble of words provided, I'd say the variable "us" is null. Why
that is I couldn't really say, but that's your problem. If it works the
first time and not the second time, it's because you've stored an object
under the name specified by PropertyConstants.USER_SELECTIONS the first time
but not the second.


0 new messages