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

What REALLY happens to your JSP code?

You write a JSP, but it becomes a servlet. The only way to really tell what’s happening is to look at what the Container does to your JSP code. In other words, how does the Container translate your JSP into a servlet?

Once you know where different JSP elements land in the servlet’s class file, you’ll find it much easier to know how to structure your JSP.

The servlet code on this page is not the real code generated by the Container—we simplified it down to the essential parts. The Container-generated servlet file is, well, uglier. The real generated servlet source code is slightly harder to read, but we will look at the real thing in a few pages. For now, though, all we care about is where in the servlet class our JSP code actually ends up.

image with no caption

Note

ALL scriptlet and expression code lands in a service method.

That means variables declared in a scriptlet are always LOCAL variables!

Note

Note: if you want to see the generated servlet code from Tomcat, look in yourTomcatHomeDir/work/Catalina/yourServerName/yourWebAppName/org/apache/jsp. (The underlined names will change depending on your system and your web app.)

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