There are a million examples on the web that shows how to create a basic Java Login Servlet, where the user has to enter a username and password which gets verified by some data
After getting the login details from the user, you can save the login details in session and in every page you can test or validate the session like...
<%
String strLoginId = (String)session.getAttribute("LoginID");
String strpassword = (String)session.getAttribute("Password");
if(strLoginId==null) // Means session is not there
%>