This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Null issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Null issue" Watch "Null issue" New topic
Author

Null issue

Nikhil Bansal
Ranch Hand

Joined: Jan 24, 2005
Posts: 60
Hi All,

We are having a strange issue.

There is currently a JSP having few fields and the request is sent to a backend procedure which fetches the JSP fields and creates a record in backend and returns a reference number to the user which is displayed as a result to the user like "Your reference no is : 1234567"

The application is working fine. However, only at a few times, null is being shown to the user, like Your reference no is : null. This is happening only a few times, something once or twice in a week and there is no straight pattern to it.

Can someone please let me know how to go about it.

Thanks,
Nikhil


ban$al
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

My best advice would be to turn on trace and look through it.

Its obviously null .... from my experience you probably encountered a runtime exception in the action controller. The way I have solved this before is I put a try catch around the execute method or whatever method the action executed and in the catch block I have done a print stack trace. You'll then see what is causing the issue ... which in most cases is probably an array index out of bounds or something like that.

Nikhil Bansal
Ranch Hand

Joined: Jan 24, 2005
Posts: 60
Hi Lucas,

Ok. Will try printing the trace.

However, as I stated, that the issue is sporadic, happening once or twice in 2-3 weeks, with no specific pattern, could there be any other reason. The reference no returned from the backend is set in user's session in action class and is then displayed to the user.

Could there be a session problem as well ?

Thanks,
Nikhil
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

nope there is something wrong with your code I highly doubt there is an issue with container if that is what your trying to say. There may be an issue with data in the session but the issue is still in your code. It can be because of something a user entered or maybe a third party your connecting with is not always sending you exactly what you think ... either way ... the only time I have ever seen such case and yes even if its sporadic has been a runtime exception in the action controller ....

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Null issue