O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The out variable isn’t the only implicit object...

When a Container translates the JSP into a servlet, the beginning of the service method is a pile of implicit object declarations and assignments.

With implicit objects, you can write a JSP knowing that your code is going to be part of a servlet. In other words, you can take advantage of your servletness, even though you’re not directly writing a servlet class yourself.

Think back to Chapter 4, Chapter 5, and Chapter 6. What were some of the important objects you used? How did your servlet get servlet init parameters? How did your servlet get context init parameters? How did your servlet get a session? How did your servlet get the parameters submitted by the client in a form?

These are just a few of the reasons your JSP might need to use some of what’s available to a servlet. All of the implicit objects map to something from the Servlet/JSP API. The request implicit object, for example, is a reference to the HttpServletRequest object passed to the service method by the Container.

image with no caption

Q:

Q: What’s the difference between a JspWriter and a PrintWriter I get from an HttpServletResponse?

A:

A: The JspWriter is not in the class hierarchy of PrintWriter, so you can’t use it in place of a PrintWriter. But it has most of the same print methods, except it adds some buffering capabilities.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required