This code doesn't seem to let the redirect work correctly. The appropriate
getters and setters are in the file, just not included here for brevity's
sake. Can someone please tell my why this tag doesn't forward me to 'path'
if 'theData' is null? I end up with a NullPointerException when this page
is run.
public class LoginOrForward extends TagSupport
{
private HttpSession session=null;
private String name;
private String type;
private String path;
public int doStartTag()
throws JspTagException
{
session=pageContext.getSession();
Object theData = session.getValue(name);
if(theData == null)
{
try
{
pageContext.sendRedirect(path);
}
catch(Exception e)
{
e.printStackTrace();
}
return SKIP_BODY;
}
pageContext.setAttribute(name,theData);
return SKIP_BODY;
}
public int doEndTag() throws JspTagException
{
/* We skipped the body, don't do a thing */
return EVAL_PAGE;
}
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets