You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mraible <ma...@raibledesigns.com> on 2007/02/27 21:29:11 UTC

Is it possible to get Struts' FilterDispatcher to serve up static files

I'm using *.html as my default extension, which causes a whole host of issues
with Dojo.  Regardless, I want to fight through it and see if I can come up
with a solution.

I noticed that FilterDispatcher allows you to serve up static files from the
classpath.  Is it possible to configure this same filter so it can serve up
static .html files from a "static" directory in my webapp root?

Thanks,

Matt
-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
Take the static content out of .jar, doesn't help the performance?
I know that taking the template directory out of jar helps a lot at
performance when rendering ui.
Doesn't it heppen the same with static content?

best,

Felipe


Musachy Barroso wrote:
> 
> I don't think so, if you set it to false, I think you will have to unzip
> all
> the dojo, and templates stuff into that folder, which is not desirable
> (unless you want to use your own version of Dojo)
> 
> musachy
> 
> On 2/28/07, Tim Azzopardi <ti...@tigerfive.com> wrote:
>>
>>
>> I think that the struts2 FAQ is here
>> http://struts.apache.org/2.0.6/docs/faqs.html
>>
>> I couldn't find anything relevant (after 3 mins). But in
>> http://struts.apache.org/2.x/docs/strutsproperties.html i saw this:
>>
>> ### Used by FilterDispatcher
>> ### If true then Struts serves static content from inside its jar.
>> ### If false then the static content must be available at
>> <context_path>/struts
>> struts.serve.static=true
>>
>> which might help?
>>
>>
>>
>>
>>
>> Musachy Barroso wrote:
>> >
>> > Is there a FAQ for S2 somewhere?
>> >
>> > musachy
>> >
>> > On 2/27/07, Musachy Barroso <mu...@gmail.com> wrote:
>> >>
>> >> Quoting the doc: "
>> >>
>> >> Common static content that is needed by the framework (JavaScript and
>> CSS
>> >> files, etc.) is served automatically by the FilterDispatcher filter.
>> Any
>> >> request starting with "/struts/" denotes that static content is
>> required,
>> >> and then mapping the value after "/struts/" to common packages in
>> Struts
>> >> 2
>> >> and, optionally in the application's class path.
>> >>
>> >> By default, the following packages are searched:
>> >>
>> >>    - org.apache.struts2.static
>> >>    - template
>> >>
>> >> Additional packages can be specified by providing a comma separated
>> list
>> >> to the configuration parameter named "packages" (configured in web.xml
>> >> for
>> >> the FilterDispatcher filter). When specifying additional static
>> content,
>> >> you
>> >> should be careful not to expose sensitive configuration information (
>> i.e.
>> >> database password)."
>> >> //I haven't used it myself :)
>> >> musachy
>> >>
>> >> On 2/27/07, mraible < matt@raibledesigns.com> wrote:
>> >> >
>> >> >
>> >> > I'm using *.html as my default extension, which causes a whole host
>> of
>> >> > issues
>> >> > with Dojo.  Regardless, I want to fight through it and see if I can
>> >> come
>> >> > up
>> >> > with a solution.
>> >> >
>> >> > I noticed that FilterDispatcher allows you to serve up static files
>> >> from
>> >> > the
>> >> > classpath.  Is it possible to configure this same filter so it can
>> >> serve
>> >> > up
>> >> > static .html files from a "static" directory in my webapp root?
>> >> >
>> >> > Thanks,
>> >> >
>> >> > Matt
>> >> > --
>> >> > View this message in context:
>> >> >
>> >>
>> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
>> >> > Sent from the Struts - User mailing list archive at Nabble.com .
>> >> >
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> > For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >>
>> >>
>> >> --
>> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >
>> >
>> >
>> >
>> > --
>> > "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9199939
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9493802
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Musachy Barroso <mu...@gmail.com>.
I don't think so, if you set it to false, I think you will have to unzip all
the dojo, and templates stuff into that folder, which is not desirable
(unless you want to use your own version of Dojo)

musachy

On 2/28/07, Tim Azzopardi <ti...@tigerfive.com> wrote:
>
>
> I think that the struts2 FAQ is here
> http://struts.apache.org/2.0.6/docs/faqs.html
>
> I couldn't find anything relevant (after 3 mins). But in
> http://struts.apache.org/2.x/docs/strutsproperties.html i saw this:
>
> ### Used by FilterDispatcher
> ### If true then Struts serves static content from inside its jar.
> ### If false then the static content must be available at
> <context_path>/struts
> struts.serve.static=true
>
> which might help?
>
>
>
>
>
> Musachy Barroso wrote:
> >
> > Is there a FAQ for S2 somewhere?
> >
> > musachy
> >
> > On 2/27/07, Musachy Barroso <mu...@gmail.com> wrote:
> >>
> >> Quoting the doc: "
> >>
> >> Common static content that is needed by the framework (JavaScript and
> CSS
> >> files, etc.) is served automatically by the FilterDispatcher filter.
> Any
> >> request starting with "/struts/" denotes that static content is
> required,
> >> and then mapping the value after "/struts/" to common packages in
> Struts
> >> 2
> >> and, optionally in the application's class path.
> >>
> >> By default, the following packages are searched:
> >>
> >>    - org.apache.struts2.static
> >>    - template
> >>
> >> Additional packages can be specified by providing a comma separated
> list
> >> to the configuration parameter named "packages" (configured in web.xml
> >> for
> >> the FilterDispatcher filter). When specifying additional static
> content,
> >> you
> >> should be careful not to expose sensitive configuration information (
> i.e.
> >> database password)."
> >> //I haven't used it myself :)
> >> musachy
> >>
> >> On 2/27/07, mraible < matt@raibledesigns.com> wrote:
> >> >
> >> >
> >> > I'm using *.html as my default extension, which causes a whole host
> of
> >> > issues
> >> > with Dojo.  Regardless, I want to fight through it and see if I can
> >> come
> >> > up
> >> > with a solution.
> >> >
> >> > I noticed that FilterDispatcher allows you to serve up static files
> >> from
> >> > the
> >> > classpath.  Is it possible to configure this same filter so it can
> >> serve
> >> > up
> >> > static .html files from a "static" directory in my webapp root?
> >> >
> >> > Thanks,
> >> >
> >> > Matt
> >> > --
> >> > View this message in context:
> >> >
> >>
> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
> >> > Sent from the Struts - User mailing list archive at Nabble.com .
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9199939
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [S2] Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Tim Azzopardi <ti...@tigerfive.com>.
I think that the struts2 FAQ is here
http://struts.apache.org/2.0.6/docs/faqs.html 

I couldn't find anything relevant (after 3 mins). But in
http://struts.apache.org/2.x/docs/strutsproperties.html i saw this:

### Used by FilterDispatcher
### If true then Struts serves static content from inside its jar. 
### If false then the static content must be available at
<context_path>/struts
struts.serve.static=true

which might help?





Musachy Barroso wrote:
> 
> Is there a FAQ for S2 somewhere?
> 
> musachy
> 
> On 2/27/07, Musachy Barroso <mu...@gmail.com> wrote:
>>
>> Quoting the doc: "
>>
>> Common static content that is needed by the framework (JavaScript and CSS
>> files, etc.) is served automatically by the FilterDispatcher filter. Any
>> request starting with "/struts/" denotes that static content is required,
>> and then mapping the value after "/struts/" to common packages in Struts
>> 2
>> and, optionally in the application's class path.
>>
>> By default, the following packages are searched:
>>
>>    - org.apache.struts2.static
>>    - template
>>
>> Additional packages can be specified by providing a comma separated list
>> to the configuration parameter named "packages" (configured in web.xml
>> for
>> the FilterDispatcher filter). When specifying additional static content,
>> you
>> should be careful not to expose sensitive configuration information (i.e.
>> database password)."
>> //I haven't used it myself :)
>> musachy
>>
>> On 2/27/07, mraible < matt@raibledesigns.com> wrote:
>> >
>> >
>> > I'm using *.html as my default extension, which causes a whole host of
>> > issues
>> > with Dojo.  Regardless, I want to fight through it and see if I can
>> come
>> > up
>> > with a solution.
>> >
>> > I noticed that FilterDispatcher allows you to serve up static files
>> from
>> > the
>> > classpath.  Is it possible to configure this same filter so it can
>> serve
>> > up
>> > static .html files from a "static" directory in my webapp root?
>> >
>> > Thanks,
>> >
>> > Matt
>> > --
>> > View this message in context:
>> >
>> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
>> > Sent from the Struts - User mailing list archive at Nabble.com .
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9199939
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Musachy Barroso <mu...@gmail.com>.
Is there a FAQ for S2 somewhere?

musachy

On 2/27/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Quoting the doc: "
>
> Common static content that is needed by the framework (JavaScript and CSS
> files, etc.) is served automatically by the FilterDispatcher filter. Any
> request starting with "/struts/" denotes that static content is required,
> and then mapping the value after "/struts/" to common packages in Struts 2
> and, optionally in the application's class path.
>
> By default, the following packages are searched:
>
>    - org.apache.struts2.static
>    - template
>
> Additional packages can be specified by providing a comma separated list
> to the configuration parameter named "packages" (configured in web.xml for
> the FilterDispatcher filter). When specifying additional static content, you
> should be careful not to expose sensitive configuration information (i.e.
> database password)."
> //I haven't used it myself :)
> musachy
>
> On 2/27/07, mraible < matt@raibledesigns.com> wrote:
> >
> >
> > I'm using *.html as my default extension, which causes a whole host of
> > issues
> > with Dojo.  Regardless, I want to fight through it and see if I can come
> > up
> > with a solution.
> >
> > I noticed that FilterDispatcher allows you to serve up static files from
> > the
> > classpath.  Is it possible to configure this same filter so it can serve
> > up
> > static .html files from a "static" directory in my webapp root?
> >
> > Thanks,
> >
> > Matt
> > --
> > View this message in context:
> > http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
> > Sent from the Struts - User mailing list archive at Nabble.com .
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd




-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [S2] Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by mraible <ma...@raibledesigns.com>.
Right, it can serve up static content from the classpath, but I want to do it
from the webapp.

Matt


Musachy Barroso wrote:
> 
> Quoting the doc: "
> 
> Common static content that is needed by the framework (JavaScript and CSS
> files, etc.) is served automatically by the FilterDispatcher filter. Any
> request starting with "/struts/" denotes that static content is required,
> and then mapping the value after "/struts/" to common packages in Struts 2
> and, optionally in the application's class path.
> 
> By default, the following packages are searched:
> 
>    - org.apache.struts2.static
>    - template
> 
> Additional packages can be specified by providing a comma separated list
> to
> the configuration parameter named "packages" (configured in web.xml for
> the
> FilterDispatcher filter). When specifying additional static content, you
> should be careful not to expose sensitive configuration information (i.e.
> database password)."
> //I haven't used it myself :)
> musachy
> 
> On 2/27/07, mraible <ma...@raibledesigns.com> wrote:
>>
>>
>> I'm using *.html as my default extension, which causes a whole host of
>> issues
>> with Dojo.  Regardless, I want to fight through it and see if I can come
>> up
>> with a solution.
>>
>> I noticed that FilterDispatcher allows you to serve up static files from
>> the
>> classpath.  Is it possible to configure this same filter so it can serve
>> up
>> static .html files from a "static" directory in my webapp root?
>>
>> Thanks,
>>
>> Matt
>> --
>> View this message in context:
>> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191703
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Musachy Barroso <mu...@gmail.com>.
Quoting the doc: "

Common static content that is needed by the framework (JavaScript and CSS
files, etc.) is served automatically by the FilterDispatcher filter. Any
request starting with "/struts/" denotes that static content is required,
and then mapping the value after "/struts/" to common packages in Struts 2
and, optionally in the application's class path.

By default, the following packages are searched:

   - org.apache.struts2.static
   - template

Additional packages can be specified by providing a comma separated list to
the configuration parameter named "packages" (configured in web.xml for the
FilterDispatcher filter). When specifying additional static content, you
should be careful not to expose sensitive configuration information (i.e.
database password)."
//I haven't used it myself :)
musachy

On 2/27/07, mraible <ma...@raibledesigns.com> wrote:
>
>
> I'm using *.html as my default extension, which causes a whole host of
> issues
> with Dojo.  Regardless, I want to fight through it and see if I can come
> up
> with a solution.
>
> I noticed that FilterDispatcher allows you to serve up static files from
> the
> classpath.  Is it possible to configure this same filter so it can serve
> up
> static .html files from a "static" directory in my webapp root?
>
> Thanks,
>
> Matt
> --
> View this message in context:
> http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9191128
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [S2] Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by mraible <ma...@raibledesigns.com>.
I came up with a StaticFilter (from http://issues.appfuse.org/browse/APF-431)
that seems to work (see code below).  However, it causes another issue for
me. In my SiteMesh decorator, I'm including a messages.jsp that has calls to
the valueStack:

<%-- ActionError Messages - usually set in Actions --%>
<s:if test="hasActionErrors()">
    <div class="error" id="errorMessages">    
      <s:iterator value="actionErrors">
         <c:url value= "
            alt="<fmt:message key="icon.warning"/>" class="icon" />
        <s:property escape="false"/><br />
      </s:iterator>
   </div>
</s:if>

<%-- FieldError Messages - usually set by validation rules --%>
<s:if test="hasFieldErrors()">
    <div class="error" id="errorMessages">    
      <s:iterator value="fieldErrors">
          <s:iterator value="value">
             <c:url value= "
                alt="<fmt:message key="icon.warning"/>" class="icon" />
             <s:property escape="false"/><br />
          </s:iterator>
      </s:iterator>
   </div>
</s:if>

When I return a static page, this JSP causes issue:

java.lang.NullPointerException
        at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58)

This works fine when I request a Struts Action.  Is there any way to check
for the stack in my messages.jsp?

Thanks,

Matt

<code>
public class StaticFilter extends OncePerRequestFilter {
    private final static String DEFAULT_INCLUDES = "*.html";
    private final static String DEFAULT_EXCLUDES = "";
    private String[] excludes;
    private String[] includes;
    public static final String INCLUDES_PARAMETER = "includes";
    public static final String EXCLUDES_PARAMETER = "excludes";

    /**
     * Read the includes/excludes paramters and set the filter accordingly.
     */
    public void initFilterBean() {
        String includesParam =
getFilterConfig().getInitParameter(INCLUDES_PARAMETER);
        if (StringUtils.isEmpty(includesParam)) {
            includes = parsePatterns(DEFAULT_INCLUDES);
        } else {
            includes = parsePatterns(includesParam);
        }

        String excludesParam =
getFilterConfig().getInitParameter(EXCLUDES_PARAMETER);
        if (StringUtils.isEmpty(excludesParam)) {
            excludes = parsePatterns(DEFAULT_EXCLUDES);
        } else {
            excludes = parsePatterns(excludesParam);
        }
    }

    private String[] parsePatterns(String delimitedPatterns) {
        //make sure no patterns are repeated.
        Set patternSet =
org.springframework.util.StringUtils.commaDelimitedListToSet(delimitedPatterns);
        String[] patterns = new String[patternSet.size()];
        int i = 0;
        for (Iterator iterator = patternSet.iterator(); iterator.hasNext();
i++) {
            //no trailing/leading white space.
            String pattern = (String) iterator.next();
            patterns[i] = pattern.trim();
        }
        return patterns;
    }

    public void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
                                 FilterChain chain) throws IOException,
ServletException {

        UrlPathHelper urlPathHelper = new UrlPathHelper();
        String path = urlPathHelper.getPathWithinApplication(request);
        boolean pathExcluded = PatternMatchUtils.simpleMatch(excludes,
path);
        boolean pathIncluded = PatternMatchUtils.simpleMatch(includes,
path);

        if (pathIncluded && !pathExcluded) {
            RequestDispatcher rd =
getServletContext().getRequestDispatcher(path);
            rd.forward(request, response);
        }

        chain.doFilter(request, response);
    }
}
</code>

Stuart Piltch wrote:
> 
> mraible <matt <at> raibledesigns.com> writes:
>> I'm using *.html as my default extension, which causes a whole host of
>> issues
>> with Dojo.  Regardless, I want to fight through it and see if I can come
>> up
>> with a solution.
> 
> Hi Matt,
> 
> I'm not sure about your specific FilterDispatcher question, but we also
> use
> *.html as a default extension. We ended up copying all the dojo html files
> that
> we use into out own /WEB-INF/widgets directory and adding an extra
> struts-dojo.xml file to our config:
> 
> <!DOCTYPE struts PUBLIC
>         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>         "http://struts.apache.org/dtds/struts-2.0.dtd">
> 
> <struts>
>     <package name="dojo" namespace="/struts/dojo/src/widget/templates"
> extends="base">
>         <action name="*">
>             <result type="plainhtml">/WEB-INF/widgets/{1}.html</result>
>         </action>
>     </package>
>     <package name="dojoEditor2"
> namespace="/struts/dojo/src/widget/templates/Editor2" extends="base">
>         <action name="*">
>             <result
> type="plainhtml">/WEB-INF/widgets/Editor2/{1}.html</result>
>         </action>
>     </package>
>     <package name="dojoEditor2Dialog"
> namespace="/struts/dojo/src/widget/templates/Editor2/Dialog"
> extends="base">
>         <action name="*">
>             <result
> type="plainhtml">/WEB-INF/widgets/Editor2/Dialog/{1}.html</result>
>         </action>
>     </package>
> </struts>
> 
> It seems convoluted, but it's working. The other dojo files (css, js, etc)
> are
> working fine from within the struts jar.
> 
> Cheers,
> 
>  - stuart
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-get-Struts%27-FilterDispatcher-to-serve-up-static-files-tf3304172.html#a9196270
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is it possible to get Struts' FilterDispatcher to serve up static files

Posted by Stuart Piltch <st...@gradientblue.com>.
mraible <matt <at> raibledesigns.com> writes:
> I'm using *.html as my default extension, which causes a whole host of issues
> with Dojo.  Regardless, I want to fight through it and see if I can come up
> with a solution.

Hi Matt,

I'm not sure about your specific FilterDispatcher question, but we also use
*.html as a default extension. We ended up copying all the dojo html files that
we use into out own /WEB-INF/widgets directory and adding an extra
struts-dojo.xml file to our config:

<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="dojo" namespace="/struts/dojo/src/widget/templates"
extends="base">
        <action name="*">
            <result type="plainhtml">/WEB-INF/widgets/{1}.html</result>
        </action>
    </package>
    <package name="dojoEditor2"
namespace="/struts/dojo/src/widget/templates/Editor2" extends="base">
        <action name="*">
            <result type="plainhtml">/WEB-INF/widgets/Editor2/{1}.html</result>
        </action>
    </package>
    <package name="dojoEditor2Dialog"
namespace="/struts/dojo/src/widget/templates/Editor2/Dialog" extends="base">
        <action name="*">
            <result
type="plainhtml">/WEB-INF/widgets/Editor2/Dialog/{1}.html</result>
        </action>
    </package>
</struts>

It seems convoluted, but it's working. The other dojo files (css, js, etc) are
working fine from within the struts jar.

Cheers,

 - stuart



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org