I'm new to jsp's and have therefore started coding my project with static repeated code on every page. For example in my head section of every page I check if there is a current user logged in, if there is then i use their name in the body section, if not i redirect to the login page.
So on my page i want the following:
<%@ page language="java"
import="com.ptm.UserBean"
%>
<!DOCTYPE html>
<html lang="en">
<head>
<title> this is my title </title>
<jsp:include page="head-section.jsp" >
</head>
<body >
<jsp:include page="header.jsp" >
</body>
</html>
in the head-section.jsp I have some html which imports jquery and my css sheet, then a jsp code block that relys on the UserBean import on the index page above then some javascript
The header.jsp include uses a jsp variable set in the head-section.jsp code block.
So my question is, these seperate jsp's that i'm including don't work on their own, but when included should work with the page, which cuts down on the ammount of repeated code i have. Is this the best way to do this? i heard about tag files, but im not sure how do implement that.
Thanks in advance for your help!