This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes having trouble checking for null value of attriibute in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "having trouble checking for null value of attriibute in jsp" Watch "having trouble checking for null value of attriibute in jsp" New topic
Author

having trouble checking for null value of attriibute in jsp

Susan Monz
Greenhorn

Joined: Aug 23, 2008
Posts: 27
Hi,

I am getting the foolowing error on my jsp because of code I have written within my scriptlet tag

Error Message: null

java.lang.NullPointerException
at _web_2d_inf._jsp._page._PagePrint._jspService(PagePrint.jsp:109)

The code is
<% if(((Number) vo.getCurrentRow().getAttribute("PageCode")).intValue() == 0){%>

I tried checking it against null and "" still threw me error. PageCode can be null. If it is null i have set some other attributes. but how do i check for null.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617



Either vo, the current row, or the current row's "PageCode" attribute is null--it'll be hard to help without knowing which is null!

Dave
Susan Monz
Greenhorn

Joined: Aug 23, 2008
Posts: 27
Thanks for replying.

Actually i do a check to make sure vo is not empty

if (vo.getRowCount() > 0) {
vo.setCurrentRow(vo.first());
}
And with my debugger I know it sets the currentRow.

PageCode is null. It is for this condition I want to code further...
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Originally posted by Susan Monz:
Thanks for replying.


PageCode is null. It is for this condition I want to code further...


If you have a doubt about 'PageCode' is null or not , then check for it , like



[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: having trouble checking for null value of attriibute in jsp
 
Similar Threads
What does this do? request.getParameter("string" + int)
Exception handling for NullPointer and more
IllegalStateException when redirecting the response...
UIData and DataTable
Date and Time as Combo Boxes