Re: Adding common header to all JSP pages

Discussion in 'Java' started by Maxim Senin/J2EE Experts at www.supremistic.com, Feb 10, 2005.

  1. Hi.

    I have a website built with JSP on tomcat 3.2. Currently is uses HTML
    frames for header/body/footer. I want to "flatten" it by getting rid of
    header and footer frames.

    I don't want to do jsp:include or anything like that in every page.
    Stylesheets may not work too: some pages can be displayed on their own, or
    same page can be included into another page, so if I did <jsp:include> on
    every page I'd get duplicated headers/footers.

    I think that the following would work for me: if I could setup some kind of
    filter for text/html content, that filter would prepend header and append
    footer to ALL pages serving text/html mime type, and i'd do it only once per
    screen.

    So how can I set up such a filter in tomcat 3.2? Do I need to change
    web.xml/server.xml or any other configuration files or deployment descripor?
    Is there any other way to do it?

    Thanks,
    Maxim
    Maxim Senin/J2EE Experts at www.supremistic.com, Feb 10, 2005
    #1
    1. Advertising

  2. Maxim Senin/J2EE Experts at www.supremistic.com

    Ryan Stewart Guest

    "Maxim Senin/J2EE Experts at www.supremistic.com" <>
    wrote in message news:f1e95$420b0885$436462d4$...
    > Hi.
    >
    > I have a website built with JSP on tomcat 3.2. Currently is uses HTML
    > frames for header/body/footer. I want to "flatten" it by getting rid of
    > header and footer frames.

    Good for you. Frames in general are going away.

    > I don't want to do jsp:include or anything like that in every page.
    > Stylesheets may not work too: some pages can be displayed on their own, or
    > same page can be included into another page, so if I did <jsp:include> on
    > every page I'd get duplicated headers/footers.

    Look at Tiles. I've only used it as a plug-in for Struts, which I'd also
    recommend, but it can be used separately. This might help you start learning
    about it:
    http://struts.apache.org/userGuide/dev_tiles.html

    Off-hand, I can't tell you how to set up up independently of Struts.

    > I think that the following would work for me: if I could setup some kind of
    > filter for text/html content, that filter would prepend header and append
    > footer to ALL pages serving text/html mime type, and i'd do it only once per
    > screen.
    >
    > So how can I set up such a filter in tomcat 3.2? Do I need to change
    > web.xml/server.xml or any other configuration files or deployment descripor?
    > Is there any other way to do it?

    That would be an unusual approach. The concept of filtering is not really for
    appending/prepending content to pages.
    Ryan Stewart, Feb 10, 2005
    #2
    1. Advertising

  3. > > So how can I set up such a filter in tomcat 3.2? Do I need to change
    > > web.xml/server.xml or any other configuration files or deployment

    descripor?
    > > Is there any other way to do it?

    > That would be an unusual approach. The concept of filtering is not really

    for
    > appending/prepending content to pages.


    Removing tags or adding new tags - what's the difference?
    Maxim Senin/J2EE Experts at www.supremistic.com, Feb 10, 2005
    #3
  4. > Removing tags or adding new tags - what's the difference?

    I suppose any servlet that modifies an original data stream can be called
    filter, isn't it?
    Maxim Senin/J2EE Experts at www.supremistic.com, Feb 10, 2005
    #4
  5. Maxim Senin/J2EE Experts at www.supremistic.com

    Steve Sobol Guest

    Ryan Stewart wrote:
    > "Maxim Senin/J2EE Experts at www.supremistic.com" <>
    > wrote in message news:f1e95$420b0885$436462d4$...
    >
    >>Hi.
    >>
    >>I have a website built with JSP on tomcat 3.2. Currently is uses HTML
    >>frames for header/body/footer. I want to "flatten" it by getting rid of
    >>header and footer frames.

    >
    > Good for you. Frames in general are going away.
    >
    >
    >>I don't want to do jsp:include or anything like that in every page.
    >>Stylesheets may not work too: some pages can be displayed on their own, or
    >>same page can be included into another page, so if I did <jsp:include> on
    >>every page I'd get duplicated headers/footers.

    >
    > Look at Tiles.


    I prefer Sitemesh. It skins HTML and JSP pages effortlessly and with little
    work, and with no includes required because it runs as a filter:

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

    I use it with Struts but it can be used outside of Struts easily. It's a
    wonderful product.

    --
    JustThe.net - Apple Valley, CA - http://JustThe.net/ - 888.480.4NET (4638)
    Steven J. Sobol, Geek In Charge / / PGP: 0xE3AE35ED

    "In case anyone was wondering, that big glowing globe above the Victor
    Valley is the sun." -Victorville _Daily Press_ on the unusually large
    amount of rain the Southland has gotten this winter (January 12th, 2005)
    Steve Sobol, Feb 10, 2005
    #5
  6. Maxim Senin/J2EE Experts at www.supremistic.com, Feb 11, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Poorna
    Replies:
    1
    Views:
    426
    Larry
    Apr 6, 2006
  2. Denny
    Replies:
    1
    Views:
    777
  3. mlt
    Replies:
    2
    Views:
    832
    Jean-Marc Bourguet
    Jan 31, 2009
  4. John Reye
    Replies:
    28
    Views:
    1,368
    Tim Rentsch
    May 8, 2012
  5. Jason Mellone
    Replies:
    3
    Views:
    94
    Jurko Gospodnetić
    May 7, 2014
Loading...

Share This Page