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.

Get Head First Servlets and JSP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.