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

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.

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