I have jsp page which contains two frames: the menu and the content. Once menu is dynamically created for a particular user there is no need to recreate it again during each request, hence I'm using frames. The problem ouccurs when user session expires. Instead of redirecting me to one frame login page, the login page is displayed in the content frame instead. So the menu is still visible.How can I redirect it to the single frame login jsp (ideally from servlet) ??
+1
A:
Since you're using JSP as server side view technology and frames are considered bad practice (poor user experience, poor SEO, developer headache), I strongly recommend to drop the frames altogether and make use of page include facilities provided by the server side view technology in question.
JSP offers you the <jsp:include>
for this. Here's a kickoff example how you could compose the includes:
<!DOCTYPE html>
<html lang="en">
<head><title>Title</title></head>
<body>
<div id="menu">
<jsp:include page="/WEB-INF/menu.jsp" />
</div>
<div id="main">
<p>Content</p>
</div>
</body>
</html>
You could cache the menu in the session scope to save the cost of regenerating on every request, although I suspect that the cost is pretty negligible. Have you profiled it?
BalusC
2010-08-19 16:40:09
Thanks. I have considered including it as jsp and menu is already cached in user session. I thought that it still be better to not retrieving menu from session object and update it at each request, but I think you are right about the headache that frames create and I'm experiencing it now.
Mike55
2010-08-19 20:15:11