3

I have the following Stripes ActionBean:

package myapp;

import net.sourceforge.stripes.action.*;

public class WelcomeActionBean extends MyAppActionBean {
    @DefaultHandler
    public Resolution view() {
        return new ForwardResolution("/welcome.jsp");
    }
}

When I load /myapp/Welcome.action in a browser, the contents of welcome.jsp are displayed.

However, when I move welcome.jsp to /WEB-INF/jsp/welcome.jsp and change the ForwardResolution argument to reflect that change, i.e.:

return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");

I get the following error when I load /myapp/Welcome.action:

net.sourceforge.stripes.exception.ActionBeanNotFoundException: Could not locate an ActionBean that is bound to the URL [/Welcome.action]. Commons reasons for this include mis-matched URLs and forgetting to implement ActionBean in your class. Registered ActionBeans are: {/controller/DefaultView.action=class net.sourceforge.stripes.controller.DefaultViewActionBean, /myapp/MyApp.action/=class myapp.MyAppActionBean, /myapp/Welcome.action/=class myapp.WelcomeActionBean, /controller/DefaultView.action/=class net.sourceforge.stripes.controller.DefaultViewActionBean, /myapp/MyApp.action=class myapp.MyAppActionBean, /myapp/Welcome.action=class myapp.WelcomeActionBean}
    net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:341)
    net.sourceforge.stripes.controller.NameBasedActionResolver.getActionBean(NameBasedActionResolver.java:264)
    net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:293)
    net.sourceforge.stripes.controller.DispatcherHelper$1.intercept(DispatcherHelper.java:106)
    net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
    net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
    net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
    net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
    net.sourceforge.stripes.controller.DispatcherHelper.resolveActionBean(DispatcherHelper.java:102)
    net.sourceforge.stripes.controller.DispatcherServlet.resolveActionBean(DispatcherServlet.java:238)
    net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:141)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)

Is it necessary to perform any special configuration in order to store JSP files in the WEB-INF directory?

2 Answers 2

5

My understanding is the following: your WelcomeActionBean in not in a package ([web, www, stripes, action]) automagically handled by the NameBasedActionResolver (read the javadoc) so it is actually mapped to /myapp/Welcome.action (as stated in the error message).

So, when you request /Welcome.action, there isn't any existing ActionBean bound to that URL and the resolver fallbacks to /welcome.jsp (again, see the NameBasedActionResolver javadoc). And when you move your JSP under /WEB-INF/jsp, well, you run out of luck and everything just fails.

To solve this, either:

  • Access the "right" (in the current state) URL binding i.e. /myapp/Welcome.action

  • Or, if you want your ActionBean to be bound to /Welcome.action by the conventions, move it in a package handled by the NameBasedActionResolver, e.g. action:

    package myapp.action;
    
    import net.sourceforge.stripes.action.*;
    
    public class WelcomeActionBean extends MyAppActionBean {
        @DefaultHandler
        public Resolution view() {
            return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");
        }
    }
    
  • Or add a @UrlBinding to your action to configure the binding explicitly:

    package myapp;
    
    import net.sourceforge.stripes.action.*;
    
    @UrlBinding("/Welcome.action")
    public class WelcomeActionBean extends MyAppActionBean {
        @DefaultHandler
        public Resolution view() {
            return new ForwardResolution("/WEB-INF/jsp/welcome.jsp");
        }
    }
    
1
  • Your tip about NameBasedActionResolver pushed me in the right direction. I was accessing /myapp/Welcome.action instead of /myapp/myapp/Welcome.action. Feb 12, 2010 at 16:56
-1

WEB-INF is a special directory, and its contents aren't accessible to the client. (It makes sense - you wouldn't want the client to be able to download your web.xml or your .class files.)

You need to move the JSP files outside of WEB-INF.

1
  • 3
    the client isn't accessing these jsps. The server is, using internal forward. It is perfectly OK to have jsps in the WEB-INF folder, if they are included or forwarded to
    – Bozho
    Feb 12, 2010 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.