When trying to access my index.jsp I get an immediate null pointer exception in RequestUtils. I've used the <logic:redirect> tag successfully in the past but I can't see what I've done wrong this time. My previous experience (when this was working) was with version 1.1-rc2 now I'm using 1.1. Any help as to why this exception is happening would be much appreciated. I've included details below.
My index.jsp is simply: <%@ taglib uri="/tld/struts-logic" prefix="logic" %> <logic:redirect forward="greetings" /> In my struts-config I have: <global-forwards type="org.apache.struts.action.ActionForward"> <forward name="greetings" path="/greetings.do" redirect="false" /> </global-forwards> <action path="/greetings" type="org.apache.struts.actions.ForwardAction" parameter="/WEB-INF/pages/greetingTest.jsp" />
The exception when I enter myContext/index.jsp is: org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) root cause java.lang.NullPointerException org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:521) org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:436) org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:396) org.apache.struts.taglib.logic.RedirectTag.doEndTag(RedirectTag.java:294) org.apache.jsp.index_jsp._jspx_meth_logic_redirect_0(index_jsp.java:82) org.apache.jsp.index_jsp._jspService(index_jsp.java:58) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) I looked at the RequestUtils source and I think that the MODULE_KEY attribute (request and application scope) is null. However I can't figure out why my configuration would be causing this. Rich
I'm having a hard time figuring out what you want to do here. The best I can figure is that you do not want the user's address bar to show .do at the end. I don't think a request will hit the Struts Controller unless it follows the pattern mapped to the Controller in your web.xml. Maybe you could change the pattern from *.do to something else, like myapp/* Wouldn't hurt to at least see if that's the problem. Good luck Rich!
A good workman is known by his tools.
Joined: May 30, 2002
I'm having a hard time figuring out what you want to do here.
I want to test the welcome file defined in my web.xml <welcome-file>/index.jsp</welcome-file> When I entered myContext/ on the address line I got the error described I my original email. Rich
Oh. Get rid of the global-forwards' forward and have index.jsp forward to greetings.do instead of just greetings. The Struts controller will direct this to the action mapped to the path /greetings The web.xml sees that it ends in .do and sends it to the Struts Controller. The Struts Controller then knows to remove the .do and finds the mapping of / + the request sans .do In this case greetings.do would be directed automagically to the action mapped with the path="/greetings" Right now your jsp is forwarding to "greetings". Because it does not end in .do, it never gets sent to the Struts Controller and so the struts-config never comes in to play.
Dear Rich, I had the exactly same problem and found a solution (for me)! I develop my web application in Eclipse with Tomcat 5.0.19. Trying to deploy it with Tomcat 4.1.8 and 4.1.30 results in the problem you encountred. So, if you develop/run with Tomcat try to upgrade to 5.0.19 if you can. Best regards, Jo�l