struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tapan Nanawati <...@inteplan.com>
Subject Error in CheckApp - CheckLoginTag - Sample example mail application
Date Tue, 01 Apr 2003 07:47:51 GMT
Hi friends,
I am working on struts -1.1 rc and tomcat 4.0.6.
I have installed  mail registration application and it is working fine.
I can see all the pages properly.


However if I open a new browser window and type the URL direcly :-
http://localhost:8080/myExample/mainMenu.jsp

I get a null pointer instead of sending me to a login page.



javax.servlet.ServletException: java.lang.NullPointerException
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.mainMenu$jsp._jspService(mainMenu$jsp.java:343)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
Cont  ~~~~~~~~~~~~
root cause
javax.servlet.jsp.JspException: java.lang.NullPointerException
at
org.apache.struts.webapp.example.CheckLogonTag.doEndTag(CheckLogonTag.java:185)
at org.apache.jsp.mainMenu$jsp._jspService(mainMenu$jsp.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)



I tried to debug and found that :
In the below method, in the request.getAttribute()
 
ModuleConfig config = (ModuleConfig) pageContext.getRequest()	
                .getAttribute(org.apache.struts.Globals.MODULE_KEY);

The *attribute* is not available and hence the null pointer.

Pleaese suggest how can I have org.apache.struts.Globals.MODULE_KEY in
the request.


   public int doEndTag() throws JspException {

	// Is there a valid user logged on?
	boolean valid = false;
	HttpSession session = pageContext.getSession();
	if ((session != null) && (session.getAttribute(name) != null))
	    valid = true;

// ERROR - null
System.out.println( "MODULE ~~ PC "+
pageContext.getRequest().getAttribute(org.apache.struts.Globals.MODULE_KEY); );


	// Forward control based on the results
	if (valid)
	    return (EVAL_PAGE);
	else {
            ModuleConfig config = (ModuleConfig)
pageContext.getRequest()	
                .getAttribute(org.apache.struts.Globals.MODULE_KEY);
            try {
		pageContext.forward(config.getPrefix() + page);
	    } catch (Exception e) {
		throw new JspException(e.toString());
	    }
	    return (SKIP_PAGE);
	}

    }



Please suggest.

Thanks

Tapan


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message