write session.jsp
<% session.getsession(false);
if(session==null)
response.sendRedirect("\login.jsp");
%>
Add this
JSP in all your jsp pages by writing following
<%@include page="session.jsp"%>
So next time if u refresh your jsp after 5 minutes and if your session has expired it will automatically redirect you to login.jsp