Error in CheckApp - CheckLoginTag - Sample example mailapplication

2003-03-31 Thread Tapan Nanawati
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



CheckLoginTag

2002-09-05 Thread Miguel Angel Mulero Martinez

I use the CheckLogonTag in all jsp (but login.jsp). The tag works well if I
use frames, but if I use tiles I get this exception:

java.lang.IllegalStateException: Cannot forward after response has been
committed'

I think if I put the CheckLogonTag in the template and not in the JSP the
think will work well, but the template calls too the login jsp, so I cannot
put the tag in the template.

Must I use two templates (one for the login and other for the rest of pages)
or there is another solution?

Thanks!!


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]