By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Objects return null pointer exception after form action getRequestURI()

P: n/a
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(PropertyConst ants.USER_SELECTIONS);
int selectedModelId = us.getModelId();

Any help would be greatful,
Mike

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"jennifer johnson" <mj********@verizon.net> wrote in message
news:1A*******************@nwrdny03.gnilink.net...
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(PropertyConst ants.USER_SELECTIONS);
int selectedModelId = us.getModelId();

Any help would be greatful,
Mike

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.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.