It's not a secret anymore!*
The moose likes Beginning Java and the fly likes design question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "design question" Watch "design question" New topic
Author

design question

ed copony
Greenhorn

Joined: Nov 29, 2001
Posts: 10
this is (probably) a "there is no right answer" question about design:
when designing a site that will have a standard header, is it considered better form to have a Header object that will get instantiated on every page just so you can call a method that does some processing/database hits and then writes the header html, or is it better to have a class with a bunch of static methods that handle this kind of thing (dynamic headers, footers, breadcrumbs, etc.). btw, i'm using jsp.
or maybe there's another way altogether...
thanks!
ed
Jignesh Malavia
Author
Ranch Hand

Joined: May 18, 2001
Posts: 81
Here's a solution
1) Create a JavaBean that handles the database.
2) Create a file header.jsp that uses the bean and displays the info.
3) In all other files include the header.jsp at the required place.
use the include directive <%@ include file='header.jsp' %> or
use the include action <jsp:include page='header.jsp' />
ed copony
Greenhorn

Joined: Nov 29, 2001
Posts: 10
that sounds good, but what if the header builds a breadcrumb that is based on a node id on the page that does the including? is there a way to get the bean some information it needs to build the correct header?
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
I am moving this to the JSP forum...


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: design question
 
Similar Threads
What are the obsolete design patterns from "J2EE Design Patterns"?
JSP Pages and i18n
Need Help w.r. to interoperability of java secure service with .net client
Problem with html layout, layout running.
design question