473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Objects return null pointer exception after form action getRequestURI()

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
1 4316
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3928
by: Toufani | last post by:
Hi everybody, I want to retrieve information about objects in active directory windows 2000 and their properties. I got some codes that don't work absolutely. for example I can't retrieve users...
9
1867
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. ...
7
1982
by: sindre | last post by:
Hi, Some place I use links to submit forms instead of a submit button. The way I have done this is: <a href="javascript:document.getElementById('<?php print "delete$i"...
5
2834
by: Tony Cheng | last post by:
for (int i=0; i<_request.Form.Count; i++ ) { string key = _request.Form.GetKey(i); if ( !key.Equals("formCode") && !key.Equals("formLanguage") && !key.Equals("__VIEWSTATE") &&...
16
6397
by: RCS | last post by:
So I have an ArrayList that gets populated with objects like: myAL.Add(new CustomObject(parm1,parm2)); I'm consuming this ArrayList from an ObjectDataSource and would like to have this support...
8
1843
by: Lüpher Cypher | last post by:
Hi, Suppose we have a hierarchical class structure that looks something like this: Object | +-- Main | +-- Object1
14
3452
by: dcassar | last post by:
I have had a lively discussion with some coworkers and decided to get some general feedback on an issue that I could find very little guidance on. Why is it considered bad practice to define a...
31
2308
by: Yevgen Muntyan | last post by:
6.2.4 of standard says: "The value of a pointer becomes indeterminate when the object it points to reaches the end of its lifetime." Do I understand it right that value of pointer may or may...
11
3221
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.