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开发者_如何学Go 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) ??
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?
精彩评论