Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Strange String compare error in JSP Page

843836May 27 2004 — edited May 27 2004
Hi,

I've a class which compiles just fine, because i know there's no error in it. there's the code of my class function.
<code>
public String getStats(String gYear,String tType)
{
if (gYear.equals("null") && tType.equals("null"))
{ query=" any thing" } ...........
return query;
}
</code>

but when I call this function through my JSP Page I get an error "java.lang.NullPointerException".
When i change my function to this if condition to this my Jsp Page doesn't give me any error
<code>
public String getStats(String gYear,String tType)
{
if (gYear == "null" && tType == "null")
{ query=" any thing" } ...........
return query;
}
</code>
Please need help in that. I've tried many thing but nothig workes. if i don't use "==" in my function i get an error in my JSP Page.

I'm running tomcat 4.0.12 and "null" is a value not a key word.
thanks for your time

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2004
Added on May 27 2004
5 comments
546 views