Java Reference
In-Depth Information
// Get the movies list object bound to the
// name “Movies”
if ( session != null ) {
movies = (String[])session.getAttribute(“Movies”);
}
N OTE
Make sure that you downcast your stored object back to its original type. While in
the HttpSession , it is stored as an object.
When you have the list of movies, thank the customer for the purchase and redisplay the list of
ordered movies. That is all there is to it. As you have seen, the Servlet API provides you with a
very elegant and simple-to-use method of maintaining persistent sessions.
Summary
In this chapter, we covered several methods that you can integrate into your servlets to handle
persistent sessions. We talked about the hidden form fields, persistent cookies, URL rewriting,
and the Servlet API's built-in session handling support. At this point, you should be able to
examine your session handling requirements and determine which method satisfies your needs.
You should also be able to implement a session handling solution based on your decision.
In the next chapter, we will look at communication between Java applets and servlets using a
method call HTTP tunneling.
Search WWH ::




Custom Search