res.setContentType("text/plain");
PrintWriter out = res.getWriter();
// The piracy check shouldn't be done in init,
// since name/port are part of request.
String key = getInitParameter("key");
String host = req.getServerName();
int port = req.getServerPort();
// Check if the init parameter "key" unlocks this server.
if (! keyFitsServer(key, host, port)) {
// Explain, condemn, threaten, etc.
out.println("Pirated!");
}
else {
// Give 'em the goods
out.println("valid");
// etc...
}