Also have a look at OpenSymphony's SiteMesh filter - it does just what
you're trying to do with your filter explanation here. SiteMesh is VERY
good!

See http://www.opensymphony.com/sitemesh/

It looks complicated, but it's not, and you can control through an XML
file which files get filtered or not (by pattern matching URLs).

The real power is that you build your jsp pages and focus on the core
presentation task in hand, then let the sitemesh filter "decorate" it by
extracting your page head, body etc and inserting those elements into a
template page (for example).

You could have a simple template that just adds extra meta tags, or
specifies the style sheet or whatever you want.

I've seen no downsides to using it, and speed is good too. Couple it with
OSCache (http://www.opensymphony.com/oscache/), and you have a couple of
blinding tools.

Hope that helps.

John Sidney-Woollett

Hertenstein Alain said:
> As for Servlet 2.3 specifications, you could easily create a Servlet
> Filter which would intercept all your requests based on your url-pattern
> (defined in web.xml), and which would do something like :
>
> RequestDispatcher reqDispatcher =
> request.getRequestDispatcher("header.jsp");
> reqDispatcher.include(request, response);
>
> And then let the filter forward to the requested page (chain.doFilter()).
> Thus all your pages would include your header.jsp file (beware not to
> include header.jsp into header.jsp file, or you'll get an infinite loop
> ;-) )
>
> This is quite easy to implement and the best way IMHO. Have a look at the
> http://java.sun.com web site for more info on Servlet Filters, they are
> very handy as soon as you understand how they work.
>
> Hope this helps,
> Alain
>
> -----Message d'origine-----
> De : Keith Hyland [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi, 24. mars 2004 16:56
> À : Tomcat Users List
> Objet : Re: JSP suggestion
>
>
> Or you can specify a prelude.jspf file in your web.xml (I think this may
> only work with servlet spec 2.4 servers)
>
> (The prelude is added to the top of the file, the coda is added to the
> end of the file)
>
> <jsp-config>
>     ....
> <jsp-property-group>
>    <display-name>allFiles</display-name>
>    <url-pattern>*.jsp</url-pattern>
>    <el-ignored>false</el-ignored>
>    <scripting-invalid>false</scripting-invalid>
>    <is-xml>false</is-xml>
>    <include-prelude>/template/prelude.jspf</include-prelude>
>    <include-coda>/template/coda.jspf</include-coda>
> </jsp-property-group>
> </jsp-config>
>
> Keith
>
> Adam Buglass wrote on 24/03/2004, 14:55:
>
>  > I use
>  >
>  > <jsp:include page="header.jsp" flush="true" />
>  >
>  > HTH.
>  > Adam.
>  >
>  >
>  > On Wed, 2004-03-24 at 14:46, Edson Alves Pereira wrote:
>  > >   Hello folks, i´d like to build a default jsp header to all my
>  > > jsp´page, in this header i would put all taglibs and imports i need,
> > but i  > > in doubt about which is the best way to do it. Sould i
> make all  > others page  > > extends this header page or do a <@ page
> import in every page? Any  > idea?  > >
>  > >   Regards,
>  > >   Edson


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to