Sitemesh 3 Exclude not working

2,112 views
Skip to first unread message

Shaunak Khedkar

unread,
Jul 7, 2011, 1:09:28 PM7/7/11
to SiteMesh 3 Users
Hi,

I am new to sitemesh and I am unable to use "exclude", so that one of
my pages does not get applied with the decorator. Following is my
sitemesh3.xml:

<sitemesh>

<mapping path="/*" exclude="false" decorator="/decorator.jsp"/>
<mapping path="/WebContent/trends/trend.jsp" exclude="true"/>

</sitemesh>

I tried all possible combinations for the 2nd mapping to exclude the
trend.jsp page, but all in vain!

Can anyone help me, how should I use it?

Thanks.

max max

unread,
Jul 7, 2011, 8:00:25 PM7/7/11
to sitemes...@googlegroups.com
same problem :) for one month :/

--- En date de : Jeu 7.7.11, Shaunak Khedkar <shaunak...@gmail.com> a écrit :

Shaunak Khedkar

unread,
Jul 8, 2011, 2:21:41 PM7/8/11
to SiteMesh 3 Users
Hi,

Problem Resolved. Apply the decorator to all the pages by using:
<mapping path="/*" exclude="false" decorator="/decorator.jsp"/>

And to exculde a particular page from being decorated by the
decorator, add <%@ page contentType="application/json" %> to the page.
(I have used contentType="applicaion/json" because I need it. You can
put others as well but not "text/html")

This is because By default, SiteMesh will only intercept responses
that set the Content-Type HTTP header to text/html.

Please refer the following site,
http://www.sitemesh.org/configuration.html and see for this section:

Advanced Configuration:

For most users, the decorator mappings above should be enough. But if
you want more options...
MIME Types

By default, SiteMesh will only intercept responses that set the
Content-Type HTTP header to text/html.

This can be altered to allow SiteMesh to intercept responses for other
types. This is only applicable for the SiteMesh Filter - it is ignored
by the offline site builder.



Thanks!!

On Jul 7, 5:00 pm, max max <stani...@yahoo.fr> wrote:
> same problem :) for one month :/
>
> --- En date de : Jeu 7.7.11, Shaunak Khedkar <shaunakkhed...@gmail.com> a écrit :

Ashish Chudasama

unread,
Jun 20, 2013, 10:51:42 AM6/20/13
to sitemes...@googlegroups.com
There is issue in  static method  WebAppContext.getRequestPath(request) because of that it is not working. I am facing the same problem so final solution is either development team can fixed this or we have to checkout the code and update the method and rebuild the jar.

Overriding wont work here as getRequestPath is static method :) 

Ashish Chudasama

unread,
Jun 20, 2013, 11:02:27 AM6/20/13
to sitemes...@googlegroups.com
One more simple solution is add custom selector to which mimic the same functionality of current one.

public Selector getSelector() {
        
            String[] mimeTypesArray = mimeTypes.toArray(new String[mimeTypes.size()]);
            return new BasicSelector(mimeTypesArray) {
                // TODO: Move the exclusion functionality into BasicSelector.
                @Override
                public boolean shouldBufferForRequest(HttpServletRequest request) {
//chnage following line with proper methdo 
                    String requestPath = WebAppContext.getRequestPath(request);
                    return super.shouldBufferForRequest(request)
                            && excludesMapper.get(requestPath) == null;
                }
            };
        
    }

On Thursday, July 7, 2011 7:09:28 PM UTC+2, Shaunak Khedkar wrote:
Reply all
Reply to author
Forward
0 new messages