Java Reference
In-Depth Information
Finally, we add a Logout link to the menu:
Download email_34/src/stripesbook/action/MenuViewHelper.java
public enum Section {
MessageList(MessageListActionBean. class ),
ContactList(ContactListActionBean. class ),
Compose(MessageComposeActionBean. class ),
Logout(LogoutActionBean. class );
}
Just like that, the Logout link appears in the menu, as shown here:
Preventing Browser Page Caching
When the user logs out from, say, the Message List page, hitting the
browser's Back button goes back to showing the list of messages—even
though the user is no longer logged in. Can we do something about
that?
The problem is that the pages within the application are being cached
by the browser. When the user clicks Back , the browser displays the
page from its cache without issuing a request to our server, and the
login interceptor doesn't get a chance to do its work.
Fortunately, we can tell the browser not to cache certain pages by
adding HTTP headers to the response. The @HttpCache annotation does
that for us. By annotating an action bean with @HttpCache(allow=false) ,
the page will not be cached by the browser:
Download email_34/src/stripesbook/action/MessageListActionBean.java
@HttpCache(allow= false )
public class MessageListActionBean extends BaseActionBean {
Now, when the user logs out from the Message List page and hits the
Back button, the browser does not show a cached Message List page.
Instead, it reissues a request, and the login interceptor sends the user
to the Login page.
Besides disallowing page caching, you can also allow caching but limit
the period of time. After the limit, the page expires, and the browser
reissues a request. To do that, indicate the number of seconds in the
expires= attribute, as in @HttpCache(expires=120) to expire the page after
two minutes.
 
 
Search WWH ::




Custom Search