Dear All,
I have encountered a small problem whilst using Tag Libraries. I have
two relatively simple tags "loggedIn" and "notLoggedIn". The purpose, is
to check whether a user is logged in or not, and display whatever is
within the tag accordingly.
However, I am encountering this exception:
java.lang.NullPointerException
at
javax.servlet.jsp.tagext.BodyTagSupport.getPreviousOut(BodyTagSupport.ja
va:190)
at
com.rd_uk.taglibrary.LoggedInTag.doEndTag(LoggedInTag.java:68)
The code in question is:
public int doEndTag() throws JspTagException
{
if (userName != null)
{
try
{
BodyContent body = getBodyContent();
body.writeOut(getPreviousOut());
body.clearBody();
}
catch (IOException e)
{
throw new JspTagException(e.toString());
}
}
return EVAL_PAGE;
}
I have read on several mailing lists, that this problem arises if
BodyContent is null. So, to remedy this, I have added a line which only
performs the getPreviousOut and clearBody operations if body != null.
However, in this instance body is obviously null, so nothing within the
tags is displayed.
What could be a reason for this, as this is critical to this tag
library?
Best regards,
Peter Dolukhanov
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com