01: package com.opensymphony.sitemesh.webapp;
02:
03: import com.opensymphony.sitemesh.SiteMeshContext;
04:
05: import javax.servlet.http.HttpServletRequest;
06: import javax.servlet.http.HttpServletResponse;
07: import javax.servlet.ServletContext;
08:
09: /**
10: * @author Joe Walnes
11: * @since SiteMesh 3
12: */
13: public class SiteMeshWebAppContext implements SiteMeshContext {
14:
15: private static final String IS_USING_STRING_KEY = "com.opensymphony.sitemesh.USINGSTREAM";
16:
17: private final HttpServletRequest request;
18: private final HttpServletResponse response;
19: private final ServletContext servletContext;
20:
21: private String contentType;
22:
23: public SiteMeshWebAppContext(HttpServletRequest request,
24: HttpServletResponse response, ServletContext servletContext) {
25: this .request = request;
26: this .response = response;
27: this .servletContext = servletContext;
28: }
29:
30: public HttpServletRequest getRequest() {
31: return request;
32: }
33:
34: public HttpServletResponse getResponse() {
35: return response;
36: }
37:
38: public ServletContext getServletContext() {
39: return servletContext;
40: }
41:
42: public boolean isUsingStream() {
43: return request.getAttribute(IS_USING_STRING_KEY) == Boolean.TRUE;
44: }
45:
46: public void setUsingStream(boolean isUsingStream) {
47: request.setAttribute(IS_USING_STRING_KEY,
48: isUsingStream ? Boolean.TRUE : Boolean.FALSE); // JDK 1.3 friendly
49: }
50:
51: public String getContentType() {
52: return contentType;
53: }
54:
55: public void setContentType(String contentType) {
56: this.contentType = contentType;
57: }
58: }
|