ForumServletpublic class ForumServlet extends HttpServlet The single servlet in the discussion forum. |
Fields Summary |
---|
private ReqHandlerRegistry | registry |
Methods Summary |
---|
public void | destroy()Closes all database connections. This method is invoked
when the Servlet is unloaded.
super.destroy();
DBUtil.closeAllConnections();
| protected void | doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
ReqHandler rh = this.registry.getHandler(request);
Renderer rend = rh.doGet(this, request, response);
rend.render(this, request, response);
| protected void | doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
ReqHandler rh = this.registry.getHandler(request);
Renderer rend = rh.doPost(this, request, response);
rend.render(this, request, response);
| public void | init(javax.servlet.ServletConfig sc)Registers all request handlers and sets up the
ForumConfig object.
super.init(sc);
// get initialization parameters from the deployment
// descriptor (web.xml)
String jdbcDriverClassName = sc.getInitParameter(
"jdbcDriverClassName");
String databaseURL = sc.getInitParameter(
"databaseURL");
String adapterClassName = sc.getInitParameter(
"adapterClassName");
ForumConfig.setValues(jdbcDriverClassName,
databaseURL, adapterClassName);
try {
// load all request handlers
this.registry = new ReqHandlerRegistry(new HomeReqHandler());
this.registry.register(new PostMsgReqHandler());
this.registry.register(new ViewMonthReqHandler());
this.registry.register(new ViewMsgReqHandler());
} catch (Exception ex) {
log(ex.getMessage(), ex);
throw new UnavailableException(ex.getMessage(), 10);
}
|
|