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


**********************************************************************
 This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


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

Reply via email to