Or you could subclass FreemarkerServlet and test wether the response has
been forwarded or not. The code inside doGet/doPost would look something
like
if (request.getAttribute("javax.servlet.forward.servlet_path") == null)) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
super.doPost(request, response);
}
Note that you might want to introduce an init parameter called needsForward,
so that you can still use the servlet inside your unit tests without
actually having to forward the request.
Of course, if servlet-mapping allowed a <dispatcher> tag (like
filter-mapping does), you'd be set as well.
Regards,
Levi
On Tue, Oct 21, 2008 at 7:30 PM, Chris Herron <[EMAIL PROTECTED]> wrote:
> As an alternative, you could create a servlet filter that maps to the
> pattern *.tfl and throws an exception or forwards to an access denied
> page and/or sets the appropriate HTTP error code.
>
> Chris.
>
> On Oct 21, 2008, at 1:11 PM, Marcus wrote:
>
> > I used Stripes with JSP and "action bean first" approach, (all JSPs
> > were under
> > /WEB-INF/jsp/)
> >
> > I used action beans like:
> >
> > @UrlBinding("some-url.xhtml")
> > public class HomeActionBean extends BaseActionBean {
> >
> > @DefaultHandler
> > @DontValidate
> > public Resolution display() {
> > return new ForwardResolution("/WEB-INF/jsp/home.jsp");
> > }
> > }
> >
> > Now I want to use FreeMaker with "action bean first" approach
> > I created "/WEB-INF/templates/home.tfl" placed freemaker jar to
> > classpath
> >
> > and changed code to:
> >
> > @UrlBinding("some-url.xhtml")
> > public class HomeActionBean extends BaseActionBean {
> >
> > @DefaultHandler
> > @DontValidate
> > public Resolution display() {
> > return new ForwardResolution("/WEB-INF/templates/home.tfl");
> > }
> > }
> >
> > Now every time I open "some-url.xhtml" in the browser I always get
> > "HTTP Status 404 - /DemoSite/WEB-INF/templates/home.tfl"
> >
> >
> > Please, note, I don't want to make free maker templates accessible
> > directly,
> > for example, by /DemoSite/home.tfl
> > like will be when I use free maker filter:
> >
> > <servlet>
> > <servlet-name>Freemarker</servlet-name>
> > <servlet-class>freemarker.ext.servlet.FreemarkerServlet</
> > servlet-class>
> > <init-param>
> > <param-name>TemplatePath</param-name>
> > <param-value>/WEB-INF/templates/</param-value>
> > </init-param>
> > <init-param>
> > <param-name>template_update_delay</param-name>
> > <param-value>0</param-value> <!-- 0 is for dev only! Use
> > higher
> > value otherwise. -->
> > </init-param>
> > <load-on-startup>1</load-on-startup>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>Freemarker</servlet-name>
> > <url-pattern>*.ftl</url-pattern>
> > </servlet-mapping>
> >
> >
> > Any suggestion, how can switch from jsp to freemaker templates
> > "action bean
> > first" approach and restrict any access to templates except through
> > action
> > beans?
> >
> >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win
> > great prizes
> > Grand prize is a trip for two to an Open Source event anywhere in
> > the world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Stripes-users mailing list
> > Stripes-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users