Reputation: 873
i have 3 jsp's :-
From a.jsp i am going to b.jsp to show some result. And when the user update one of the record i call c.jsp which actually update it. So after updation it forward to a.jsp with a message saying "Successfully Updated" . And i set this message in session . And in a.jsp after showing this message. i invalidate the session.
The problem is , when i press the browser back button it still show the message. How can i solve this. Please help me. Thanks
Upvotes: 0
Views: 584
Reputation: 3753
If a.jsp, b.jsp and c.jsp are a part single process, try putting them on single page (say abc.jsp). Now using some attributes show contents of either a.jsp/b.jsp/c.jsp, something similar to a wizard.
Upvotes: 0
Reputation: 3082
I would suggest few steps to do that...
As you click on back button browser will get the page from cache... so set the JSP page Expires
date to some previous day/time to get it from server(origin) instead of cache. This can be done by writing a Custom tag and in that tad set Expires
header on HttpServletRequest
object and adding that tag to JSP page is enough.
To invalidate the page and redirect to a.jsp when there is no valid session, write a Filter
to that job.
Tag can be written like this
public class ExpiryTag extends SimpleTagSupport{
@Override
public void doTag() throws JspException, IOException {
PageContext pageContext = (PageContext) getJspContext();
Calendar instance = Calendar.getInstance();
instance.add(Calendar.DAY_OF_MONTH, -1);
HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
response.addHeader("Expires", instance.getTime().toString());
}
}
Map tag in tld file like this
<tag>
<name>expired</name>
<tag-class>com.analysis.mvc.tags.ExpiryTag</tag-class>
<body-content>empty</body-content>
</tag>
Then use the tag in JSP like this
<prefix:expired/>
For session handling you can go through this for basic understanding.
Upvotes: 1