This example uses JSP to show a header on every page.
It starts with a header.html file that contains the header:
<div style="border: thin solid black; padding:5px;">
<a href="index.jsp">Home</a>
<a href="about.jsp">About</a>
<a href="pictures.jsp">Pictures</a>
</div>
Then it contains a few JSP files that each include the header:
index.jsp
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
</head>
<body>
<%@ include file = "header.html" %>
<p>Welcome to my homepage!</p>
</body>
</html>
about.jsp
<!DOCTYPE html>
<html>
<head>
<title>About</title>
</head>
<body>
<%@ include file = "header.html" %>
<p>About me: I'm an example!</p>
</body>
</html>
pictures.jsp
<!DOCTYPE html>
<html>
<head>
<title>Pictures</title>
</head>
<body>
<%@ include file = "header.html" %>
<p>This page will contain pictures I've taken.</p>
</body>
</html>
Use Jakara Server Pages to show a header on every page.
Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!
Comments are powered by the Happy Coding forum. This page has a corresponding forum post, and replies to that post show up as comments here. Click the button above to go to the forum to post a comment!