Click to See Complete Forum and Search --> : help! I'm dying here. (Mail form null pointer)


Kelly
03-27-2003, 12:59 AM
here's my problem child web page: :(

my problem page (http://pages.ivillage.com/kelly6199/stressotypeanalysis/id1.html)

I have no idea what happened. It worked fine and then one fine day it started throwing a "java.lang.NullPointerException" when submitted. :confused:

More people are starting to become aware of this stress-o-type test I'm doing and it really s*cks to have this thing go off like this. What can I say it's embarrasing!

Can someone that knows how to correct this please help me?

What might be quite simple to you is daunting to a novice javascript guy like me. I felt good to get so far as to create this survey and have it work several times. Now for some strange reason it's decided to jerk me around. :mad:

Is there some handy dandy easy way to fix this. Is there a mail form debugging tool or something that could do this? I'm trying to look at debugging tools but the learning curve is well you know. I hope to get this fixed fast and I can't learn everything all at once.

Any suggestions, directions or direct help is appreciated. :cool:

Scriptage
03-27-2003, 06:24 AM
This is a javascript forum not Java. There is a hell of a difference between the two, so you may not get many people who know java. I only know a little but I may be able to help.

java.lang.NullPointerException is thrown when an application attempts to use null in a case where an object is required ie:
Calling the instance method of a null object.
Accessing or modifying the field of a null object
Taking the length of null as if it were an array
Accessing or modifying the slots of null as if it were an array
Throwing null as if it were a Throwable value

I'm guessing that you only get the error when all of the fields aren't filled out.. so what you might need to do is to define all of your variables and objects before using them. If you try to define an object/variable by a parameter that hasnt been passed or is null then you get a null value in the variable/object. Try defining the variables as ""; before defining them by the parameters passed.
Regards
Carl

Kelly
03-27-2003, 08:05 AM
Thanks for your reply!

Am I thinking this is a javascript problem when it is a java problem?

Should I be looking for a java debugger instead of javascript?

These two still confuse me.

So If I'm hearing you correctly. How would I define objects? I am thinking that what I am hearing is telling me to look at the form inputs and in cases of select boxes make sure that no select options have empty fields or something is that it?

What about text area boxes they are inherently empty how would I put something in them if the person filling out the form doesn't type anything?

:confused:

Should I try the java forum here instead of this one?

hum

Scriptage
03-27-2003, 08:49 AM
Hey,
What I was meaning is that...you propably used something like this:


<%
String name;
name =request.getParameter("name")%>


I suggested to do:


<%
String name;
name = "";
name =request.getParameter("name")%>


But on reflection that would not work.

You need to use the following:


<%
String name;
if (request.getParameter("name") == null) {
name = "";
} else {
name = request.getParameter("name");
}
%>


This should stop the Null Pointer Exception.
In the First example if there wasn't a parameter "name" then the string name would be set to null; therefore when you came to use that information the jsp would throw a nullPointerException.

The last example checks to see if the parameter "name" is there, if it is then the value of name is set to the parameter "name", otherwise it is set to "".

In the middle example the string name is set to "" and is then set to the parameter("name") which wouldn't make any difference to the code, a nullPointerException would sill be thrown.

Am I thinking this is a javascript problem when it is a java problem?

Javascript is a scripting language for client side programming. Java is a full blown programming language. There are a lot of differences between the two. You are using java

Regards
Carl

Kelly
03-27-2003, 10:11 AM
I am using java?

Ok I chatted a little in a yahoo chat room for programming about this. I didn't know where else to go. There is no Java forum here that I can see.

so long story short I don't know what "I" am using.

I am using a website builder on ivillage. I have learned just enough html to create a web gem and then copy and paste it into a notepad and duplicate parts of it to make all the necessary inputs and then recopy the whole thing back into the page builder in a feature that lets me add my own html.

the "code" behind all this I have no idea how to access or alter.

What you are suggesting here at the end of your post is that I add some single piece of code that will take care of it?!!!!!

If I can do that with the limited access I have to the front end of this whole thing that would be an answer to my prayer!

All I can see and do with my skill level at this point is view source, copy it to a notepad and then change whatever needs changing and then recopy it back into the pagebuilder in an "add your own html" window and then delete the original.

If what I enter into that html window doesn't work I have no idea how to change it so it does.

I am limited by what I don't know and perhaps by limited administrative access. I just have a basic bare bones homepage account and I have the webtools that they provide.

That and trying to get my hands on tutorials as fast as i learn in every spare moment.:rolleyes: :D

if there really is something simple that i can add in that crude fashion that will fix all this.

could you help me craft what I should add? is that what you just did and it's already right in front of me? Could it really be that easy?

would adding one little piece somewhere do it all?

where do i add the patch?

do i need to locate instances that are messing up even?

Scriptage
03-27-2003, 12:39 PM
I assumed that you programmed the jsp page when you said that you created it, fair enough.
It seems to me that the error is in either the jsp code (if you altered it) or on the server configuration if not. If it just started to not work one day...ie throwing the nullPointerException and you didn't change anything then it's probably something to do with the server.
The best thing you can do is to get in touch with the webmaster at ivilliage and he/she'll sort it out for you.

Regards
Carl

Kelly
03-27-2003, 03:54 PM
thanks for all your help at least I have some idea where the problem lies. I don't know how much I can do about it unless the webmaster for ivillage can become motivated. I have sent an email to them. I don't know how motivated they will be to help someone with a free homepage issue.