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. Ideally it should send me to the 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to