• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Header & Footer with JSP

 
Moses Babylone
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do note that <jsp:include page=...> is for dynamic content and <%@include file=...> is for static content.
 
d v lokesh venkata
Greenhorn
Posts: 16
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you are going with using of css templates you can go with <%@include----
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic