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

Kim wants to configure his email address in the DD, not hard-code it inside the servlet class

image with no caption

Here’s what Kim does not want in his servlet:

PrintWriter out = response.getWriter();
out.println("blooper@wickedlysmart.com");

Note

Hard-coding the address is BAD!

What happens when his email changes? He’ll have to recompile...

He’d much rather put his email address in the Deployment Descriptor (web.xml file) so that when he deploys his web app, his servlet can somehow “read” his email address from the DD. That way, he won’t have to hard-code his address in the servlet class, and to change his email he modifies only the web.xml file, without having to touch his servlet source code.

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