aspose file tools*
The moose likes JSP and the fly likes Header & Footer with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Header & Footer with JSP" Watch "Header & Footer with JSP" New topic
Author

Header & Footer with JSP

Moses Babylone
Greenhorn

Joined: Aug 01, 2013
Posts: 3
Hello,
I am a newbie for JAVA and jsp.
I have a fix code for header and for footer which I want to use for all my pages. I don't want to duplicate it. In PHP, we can do this by creating a file header.php and footer.php and including these files whenever required.
I am wondering how I can do the same with jsp? I want to create header and footer and include them in the pages. I don't want to create a template though. Not all pages use same header and footer. So, I must have a flexibility to choose where I could include these 2 files or not.

Thanks!
d v lokesh venkata
Greenhorn

Joined: Aug 09, 2013
Posts: 16

you can achieve the same in jsp by using <jsp:include> tag or <%@include --->
save the header part in header.jsp and footer part in footer.jsp
do the following
<%@include file="header.jsp">
/////////////////your code//////////////
/////////////////your code//////////////
/////////////////your code//////////////
<%@include file="footer.jsp">
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1966
    
    7

Do note that <jsp:include page=...> is for dynamic content and <%@include file=...> is for static content.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
d v lokesh venkata
Greenhorn

Joined: Aug 09, 2013
Posts: 16

when you are going with using of css templates you can go with <%@include----
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

d v lokesh venkata wrote:when you are going with using of css templates you can go with <%@include----


Which type of include is used in irrelevant with respect to using CSS on the page or not.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Header & Footer with JSP
 
Similar Threads
Getting include to work
sharing tiles / definitions across applications
Difference Between jsp include directive and include action element.
Design choice for dispatching request to view
How to add HTML tags to Response Servlet