Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

How to include boilerplate (headers, footers) in web pages.

Thread view: 
news.rcn.com - 21 Jan 2006 18:48 GMT
I want to include static features in all pages of a web site-  things like
banners, main menus, etc. - and would like some help in what is the
'standard' way(s) to do this.
I've done this before using Java Server pages which have an include
directive but JSP is not an option.

It appears that server side includes (SSI) and scripting (CGI) are the
options. (JSP and ASP are not available from the web host).  Is there
another approach?

It seems overkill to make every page on the site a script when most pages
are static but I don't want to have copies of the boilerplate that have to
be maintained in every file.

Thanks in advance for your advice.

jim
jcsnippets.atspace.com - 21 Jan 2006 22:09 GMT
> I want to include static features in all pages of a web site-  things like
> banners, main menus, etc. - and would like some help in what is the
[quoted text clipped - 13 lines]
>
> jim

Hi Jim,

Maybe this can help you - it's a tool I've written a while ago to simulate
the behaviour of SSI. I've just put it online.
http://jcsnippets.atspace.com/java/htmlssi.html

Best regards,

JC
--
http://jcsnippets.atspace.com
a collection of source code, tips and tricks
Danno - 21 Jan 2006 22:12 GMT
Some java approaches often taken are:

Struts tiles (even if you don't use struts, you can use tiles) :
http://struts.apache.org
Sitemesh : http://www.opensymphony.com/sitemesh/
Raymond DeCampo - 22 Jan 2006 01:02 GMT
> I want to include static features in all pages of a web site-  things like
> banners, main menus, etc. - and would like some help in what is the
[quoted text clipped - 9 lines]
> are static but I don't want to have copies of the boilerplate that have to
> be maintained in every file.

You might try pre-generating the static files with the headers and
footers.  Roedy Green who posts here often has a tool for this I believe.

HTH,
Ray

Signature

This signature intentionally left blank.

Roedy Green - 22 Jan 2006 08:31 GMT
On Sun, 22 Jan 2006 01:02:12 GMT, Raymond DeCampo
<nospam@twcny.rr.com> wrote, quoted or indirectly quoted someone who
said :

>You might try pre-generating the static files with the headers and
>footers.  Roedy Green who posts here often has a tool for this I believe

I have system for generating a website statically. .  It has a number
of parts.

1. macro expansion.  You write the macros in Java.  You can look on my
website and see what some of them can do. It is nice having the full
power of java to do file i/o and other thing you could imagine. Search
for the word "macro".  I can so some SSI-like stuff like file date and
size inclusion. There is a nestable include macro. I can't do hit
counts, at least not up-to-date ones.  Macros that save me a lot of
time are  Image that inserts the width and height automatically.
headers and footers that are quite clever, and of course nicely
encapsulated. You just change the say the copyright display method and
bang tho whole site is fixed. Book Refer  generate links to muliple
bookstores.  Links about Java versions, directories, JavaDoc and
filenames all automatically kick over when a new Sun version comes
out. I can do  all the same things you can in JSP, with the
restriction I have to have the data at Upload time. I can't wait for
the user to tell me something.

2. compression.  It remove excess whitespace from the HTML to speed
downloads.  Someday I might take it a step futher and remove all
comments and the macro original text too.

3. index generation.  I have various glossaries and it builds master
and letter level index pages.

4. Untouching.  This redates files back to what they used to be if
they have not really changed.  It gets rid of any spurious updates to
avoid uploads.

5. JDisplay with preprocessse listings to colourise them and embed
them either as applets or HTML. It can handle HTML, XML, Java, SQL,
BAT,  ini, csv, properties etc. It has robust parsers that can handle
fragments and bad code.

6. replicator. Allows people to maintain an up to date mirror with
minimal downloading.

I have used this myself gradually improving it over the years not
worrying to much about generality.

I have not published it.  If someone is interested, I can get around
to packaging it up. It requires a Java programmer to use, since you
need to write or modify the macros for your own site.

Why bother?  why not use JSP?  You have no budget.  You don't have
access to a powerful enough JSP server to generate content
dynamically.   This all works with a vanilla HTTP server with FTP
upload.

The other reason is you want to generate content to be read offline.
JSP can't do that.  You can distribute your website on CD and it is
readable.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Raymond DeCampo - 22 Jan 2006 14:45 GMT
> On Sun, 22 Jan 2006 01:02:12 GMT, Raymond DeCampo
> <nospam@twcny.rr.com> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 5 lines]
> I have system for generating a website statically. .  It has a number
> of parts.

[snip]

> Why bother?  why not use JSP?  You have no budget.  You don't have
> access to a powerful enough JSP server to generate content
[quoted text clipped - 4 lines]
> JSP can't do that.  You can distribute your website on CD and it is
> readable.

Roedy,

Another good reason is that by pre-generating the files once, you save
the cost of having to generate the response every time with a dynamic
technology like JSP.  If the pages are static, there is no point to
building them over and over again...

Ray

Signature

This signature intentionally left blank.

Roedy Green - 23 Jan 2006 01:44 GMT
On Sun, 22 Jan 2006 14:45:02 GMT, Raymond DeCampo
<nospam@twcny.rr.com> wrote, quoted or indirectly quoted someone who
said :

>> Why bother?  why not use JSP?  You have no budget.  You don't have
>> access to a powerful enough JSP server to generate content
[quoted text clipped - 11 lines]
>technology like JSP.  If the pages are static, there is no point to
>building them over and over again...

That's what I was hinting at with the "powerful enough JSP server".  I
obviouly takes a lot more work on your server's part to do dynamic
generation. With my scheme, all the server has to do is hand the file
out without processing.  If generated files are absolulely identical
for a while, then they can be better cached at various levels. If you
regenerate each time, each one is considered unique and can't very
well be cached anywhere.

I am working up a Java glossary entry to explain this.

IT will be called  http://mindprod.com/jgloss/htmlstaticmacros.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 23 Jan 2006 08:56 GMT
On Mon, 23 Jan 2006 01:44:27 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>That's what I was hinting at with the "powerful enough JSP server".  I
>obviouly takes a lot more work on your server's part to do dynamic
[quoted text clipped - 7 lines]
>
>IT will be called  http://mindprod.com/jgloss/htmlstaticmacros.html

It is now posted. Whew. A lot more work than I thought it would be.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 23 Jan 2006 09:37 GMT
On Sun, 22 Jan 2006 14:45:02 GMT, Raymond DeCampo
<nospam@twcny.rr.com> wrote, quoted or indirectly quoted someone who
said :

>Another good reason is that by pre-generating the files once, you save
>the cost of having to generate the response every time with a dynamic
>technology like JSP.  If the pages are static, there is no point to
>building them over and over again...

I have posted my essay on the advantages and disadvantages of HTML
static macros. I came up with 11 advantages and 4 disadvantages.

see http://mindprod.com/jgloss/htmlstaticmacros.html

I also describe the tools I wrote to implement them.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Tim B - 22 Jan 2006 10:05 GMT
> I want to include static features in all pages of a web site-  things like
> banners, main menus, etc. - and would like some help in what is the
[quoted text clipped - 13 lines]
>
> jim

You could create a javascript file with functions that return the html for a
banner,  menu, etc. Include a reference to this file in each html page, plus
appropriately id'ed div tags. Then in a javascript block set the innerHTML
value of each div to the value returned by the corresponding function. This
block must be after the last div being set.

advantage: banner and menu html in one file only.
disadvantage: site will be unusable without javascript, plus it's maybe  a
bit hokey.

Personally, I'd just get a different web host that supports jsp


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.