Search code examples
jspjstldecoratorresponsive-designsitemesh

Pass a variable from Sitemesh Decorator


We have a system which uses multiple decorators for different sized pages, whilst using the same content pages. I'm trying to set a variable which can be passed to the content pages (which are written in JSP). e.g.

<c:set var="pagetype" value="mobile/" />

This method does not work because the content pages are sent to the decorator and thus need to be generated first. Is there a way to pass a variable into the pages before they are compiled, so that for instance I can use responsive images in different folders with different decorators (e.g.

<img src="uploads/${pagetype}/img.jpg />

Solution

  • Solution is to add it to the request scope:

    <c:set var="pagetype" value="mobile/" scope="request" />