01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: ServletUtils.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.tools;
09:
10: import com.uwyn.rife.engine.Response;
11: import javax.servlet.http.HttpServletRequest;
12:
13: public abstract class ServletUtils {
14: public static String getServletDir(HttpServletRequest request) {
15: String servletpath = request.getServletPath();
16: if (null != servletpath) {
17: int lastindex = servletpath.lastIndexOf("/");
18:
19: if (-1 != lastindex) {
20: return servletpath.substring(0, lastindex + 1);
21: }
22: }
23: return "";
24: }
25:
26: public static void preventCaching(Response response) {
27: response.addHeader("Cache-Control", "no-cache"); // HTTP/1.1
28: response.addHeader("Cache-Control", "no-store"); // HTTP/1.1
29: response.addHeader("Cache-Control", "must-revalidate"); // HTTP/1.1
30: response.addHeader("Pragma", "no-cache"); // HTTP 1.0
31: response.addHeader("Expires", "1");
32: }
33: }
|