KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > web > util > DjenericServlet


1 package com.genimen.djeneric.web.util;
2
3 import javax.servlet.ServletConfig JavaDoc;
4 import javax.servlet.ServletException JavaDoc;
5 import javax.servlet.http.HttpServlet JavaDoc;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.http.HttpServletResponse JavaDoc;
8
9 public abstract class DjenericServlet extends HttpServlet JavaDoc
10 {
11
12   protected ServletConfig JavaDoc _config = null;
13
14   public void init(ServletConfig JavaDoc config) throws ServletException JavaDoc
15   {
16     super.init(config);
17
18     _config = config;
19   }
20
21   protected void disableBrowserCaching(HttpServletResponse JavaDoc response)
22   {
23     response.setHeader("Pragma", "no-cache"); //HTTP 1.1
24
response.setHeader("Cache-Control", "no-cache"); //HTTP 1.0
25
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
26
}
27
28   protected String JavaDoc getContextroot(HttpServletRequest JavaDoc request)
29   {
30     return request.getContextPath();
31   }
32
33   protected String JavaDoc getConfig(String JavaDoc paramName)
34   {
35     return _config.getInitParameter(paramName);
36   }
37
38 }
Popular Tags