I fought this same problem recently... Your request to get the .jsp does not flow through the Struts ActionServlet. It's the ActionServlet that stores a reference to the current (sub-application) configuration object in the Request. When the struts FormTag.doStartTag is executed it tries to pull this reference from the Request, it's not there - so it tries to pull it from the servlet context. It does find one in the servlet context, but this is the main configuration object, not the sub-app specific one. The specific sub-app action is not defined in the main struts-config file, so it's not found in the main app config object, and this error message is emitted.
My work-around for this problem was to add a new attribute to the FormTag called subApplication, that can be used in the FormTag.lookup method to find the correct sub-application configuration object - stored in the servlet context under the tag "Action.APPLICATION_KEY+"/subapplicationname" (as you point out). Perhaps not the most ellegant solution, but it works for us... BTW, someone's probably going to point out that requests to get the .jsp directly are not correct to begin with... but, if the page in question has any local (thispage.jsp#foo) hrefs, the browser is going to re-request the page anyway - forcing this problem to surface. Good luck, Ralph > -----Original Message----- > From: Vlad Baranovsky [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 18, 2002 2:48 PM > To: [EMAIL PROTECTED] > Subject: Accessing pages within a sub-application > > > Hello, I was wondering if someone might have insight into the > following problem: > > I have a struts-based application to which I have added a > sub-application. When I try to directly access a .jsp file that > belongs to the sub-application and has an <html:form> tag in it, > I receive the following exception: > > javax.servlet.jsp.JspException: Cannot retrieve mapping for > action /doSomething at > org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:828) at > org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:528) > > ..where the action "doSomething" is defined in the > sub-application's struts-config.xml file. > > By looking at the tag library source code and doing some tests, > I've discovered that the the cause of the problem might be here > (the first few lines of the lookup method of FormTag): > > appConfig = (ApplicationConfig) > pageContext.getRequest().getAttribute(Action.APPLICATION_KEY); > if (appConfig == null) { // Backwards compatibility hack > appConfig = (ApplicationConfig) > > pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY); > } > > It appears that the "backwards compatibility hack" is invoked, > and the application config object is retrieved from the servlet > context, rather than the request. Because the sub-application's > config object is located under the key > "Action.APPLICATION_KEY+"/subapplicationname" in the servlet > context, the config object for the main application is retrieved, > and consequently, the mapping for the action cannot be found. If > this .jsp file is forwarded to by an action, however, the correct > config object is retrieved from the request, and the page loads > without exceptions. > > My question is, am I misunderstanding something? Or is there no > support for this kind of operation? (meaning, just typing the > URL of such a .jsp into a browser) Any suggestions would be appreciated. > > Thanks, > Vlad > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>