Skip to Content
Head First Servlets and JSP, 2nd Edition
book

Head First Servlets and JSP, 2nd Edition

by Bryan Basham, Kathy Sierra, Bert Bates
March 2008
Intermediate to advanced
911 pages
20h 31m
English
O'Reilly Media, Inc.
Content preview from Head First Servlets and JSP, 2nd Edition

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First Java, 2nd Edition

Head First Java, 2nd Edition

Kathy Sierra, Bert Bates
Head First Java, 3rd Edition

Head First Java, 3rd Edition

Kathy Sierra, Bert Bates, Trisha Gee
Learning Java, 6th Edition

Learning Java, 6th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 9780596516680Errata PageSupplemental Content