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 2007

Tip: Looking for answers? Try searching our database.

Best practice for managing jsp segments?

Thread view: 
Steve - 04 Jan 2007 19:29 GMT
Hi,

I hope this is the right newsgroup; it was the best I could find. If there
is a better one please direct me. Thanks.

OK, I'd like to know if there is a 'best practice' for managing the
following scenario:

I have a web-based project (in Eclipse) with some jsp files and in the best
tradition I have modularized them so the top level jsp has many
<jsp:include> tags to include other parts. Now, I am using stylesheets
extensively and I'm having problems working out the best way to get the
stylesheets included in the page.

Here's a (very simple) example to help:

page.jsp:

   <html>
       <head>
           <link href="css/main.css" ... />
       </head>
       <body>
           <jsp:include page="header.jsp" />
           <jsp:include page="tabs.jsp" />
           <jsp:include page="body.jsp" />
           <jsp:include page="footer.jsp" />
       </body>
   </html>

tabs.jsp (for example) defines a <div> and a nested <ul>. Both use a style
class that I define in a stylesheet.

Obviously, whatever page tabs.jsp is included from (potentially many) needs
to link to that stylesheet. So - how do I link to it? Probably not so
difficult in this small example since I could add a <link> for the tabs
stylesheet.

It could get messy with many nested includes. And, potentially conditional
includes as well. How do I know beforehand (at the <head> tag) which styles
I will need? It would be nice if each .jsp segment could define the
stylesheet it needs and somehow get that magically transported back in time
to a <link> tag!

I've seen other sites compromise and have just one all-encompassing
stylesheet for everything. Is this the best way to go?

Thanks for any advice.

Signature

Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"

Chris - 04 Jan 2007 22:34 GMT
> I've seen other sites compromise and have just one all-encompassing
> stylesheet for everything. Is this the best way to go?

I think so. Styles can be written in a fairly compact way, and it would
unusual to need a really big one. An unchanging style sheet will get
cached by the browser, so after your user has hit the first page of your
site, then will be no need ever to fetch the sheet again.

Plus, you're going to have common styles across all the sub pages, so
you need to have at least one common style sheet anyway.
Lew - 05 Jan 2007 02:35 GMT
Steve wrote:
> I have a web-based project (in Eclipse) with some jsp files and in the best
> tradition I have modularized them so the top level jsp has many
> <jsp:include> tags to include other parts. Now, I am using stylesheets
> extensively and I'm having problems working out the best way to get the
> stylesheets included in the page.

> Plus, you're going to have common styles across all the sub pages, so
> you need to have at least one common style sheet anyway.

I do not find big use of <jsp:include> to be a best practice. At all.

On most projects where it (or <%@include...%>) figured prominently, they only
served to fragment the layout, which is IMHO better apprehended when all in a
single artifact (at least, per frame, and exclusive of independent header or
footer blocks). Not only that, there are interactions wrt variable
declarations (in <jsp:useBean...> and the like) that can make maintenance a bitch.

I'd stay away from includes and modularize using backing logic beans, tag
libraries and the MVC pattern instead.

- Lew
Berlin  Brown - 06 Jan 2007 00:08 GMT
> Hi,
>
[quoted text clipped - 51 lines]
> "...which means he created the heaven and the earth... in the DARK! How good
> is that?"

That is what I have been using?

Berlin Brown
http://www.botspiritcompany/botlist


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.