Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Workshop

This workshop tests whether you understand all the concepts you learned today. It's a good idea to master today's concepts by honing your knowledge here before starting tomorrow's material. You can find the answers to the quiz questions in Appendix A.

Quiz

  1. What are the names of the Cookie object methods you use to find a cookie's name and value?

  2. What is the default timeout for a session in the Tomcat server?

  3. How do you know if Tomcat can't establish a session with the user's browser?

  4. What possible scopes can you use with JavaBeans in JSP?

  5. What is the default setting for the page directive's session attribute?

Exercises

  1. Create a sample home page that accepts a person's name and birthday using text fields (use text fields for the name, birth month, and birth day) and stores that information using a cookie that lasts a year. Then use the Date and Calendar classes you saw in Day 6, "Creating JSP Components: JavaBeans," to display a greeting to the person on his birthday.

  2. Try repeating the JavaBean example in the topic "Using Sessions, Applications, and JavaBeans," but this time, give the bean application scope to create a Web page counter that uses the counter in the bean to indicate the total number of times the page has been accessed by anyone, and then test it out. Also, use the application object's setMaxInactiveInterval method to set the application timeout to a second or two and watch what happens to the counter as the application times run out over repeated page reloads.

  • + Share This
  • 🔖 Save To Your Account