Source Code Cross Referenced for Response.java in  » Portal » Open-Portal » com » sun » portal » providers » jsp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.providers.jsp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.providers.jsp;
006:
007:        import java.util.Locale;
008:
009:        import java.io.IOException;
010:        import java.io.PrintWriter;
011:        import java.io.StringWriter;
012:        import java.io.UnsupportedEncodingException;
013:
014:        import java.net.URL;
015:        import java.net.MalformedURLException;
016:
017:        import javax.servlet.ServletOutputStream;
018:        import javax.servlet.http.HttpServletResponse;
019:        import javax.servlet.http.Cookie;
020:
021:        import com.sun.portal.providers.ProviderException;
022:        import com.sun.portal.providers.context.ProviderContext;
023:
024:        import com.sun.portal.desktop.util.NSStringWriter;
025:        import com.sun.portal.desktop.util.NSPrintWriter;
026:        import com.sun.portal.desktop.RequestThreadLocalizer;
027:
028:        /*
029:         * The Response is an internal representation for the response that is
030:         * generated by the JSP servlet. This version of Response adds a
031:         * getLocation method to read the Location header after the response
032:         * is completed.  This is used for the processEdit functionality.
033:         **/
034:
035:        class Response implements  HttpServletResponse {
036:            private static final String headerMsg = "headers cannot be modified by JSP providers";
037:
038:            protected String characterEncoding = System.getProperty(
039:                    "file.encoding", "iso-8859-1");
040:            protected PrintWriter writer = null;
041:            protected StringWriter stringWriter = new NSStringWriter(4096);
042:            protected Request request;
043:            protected HttpServletResponse servletResponse;
044:            protected boolean usingStream = false;
045:            protected boolean usingWriter = false;
046:            protected boolean started = false;
047:            protected boolean committed = false;
048:            private String location = null;
049:            protected int status = 200;
050:            protected ProviderContext context;
051:
052:            public Response(Request req, HttpServletResponse res,
053:                    ProviderContext c) {
054:                request = req;
055:                servletResponse = res;
056:                context = c;
057:            }
058:
059:            public URL getLocation() throws MalformedURLException {
060:                if (location == null) {
061:                    return null;
062:                }
063:                URL loc = new URL(location);
064:                return loc;
065:            }
066:
067:            public StringBuffer getBody() throws ProviderException {
068:                return stringWriter.getBuffer();
069:            }
070:
071:            public void addCookie(Cookie cookie) {
072:                servletResponse.addCookie(cookie);
073:            }
074:
075:            public String encodeRedirectURL(String url) {
076:                // we don't support url rewriting yet!
077:                return url;
078:            }
079:
080:            public void resetBuffer() {
081:                //do nothing
082:            }
083:
084:            /**
085:             * @deprecated
086:             */
087:
088:            public String encodeRedirectUrl(String location) {
089:                return encodeRedirectURL(location);
090:            }
091:
092:            public String encodeURL(String url) {
093:                // we don't support url rewriting yet!        
094:                return url;
095:            }
096:
097:            /**
098:             * @deprecated
099:             */
100:            public String encodeUrl(String url) {
101:                return encodeURL(url);
102:            }
103:
104:            public String getCharacterEncoding() {
105:                return characterEncoding;
106:            }
107:
108:            // mark whether or not we are being used as a stream or writer
109:            public ServletOutputStream getOutputStream() {
110:                throw new IllegalStateException("stream output not supported");
111:            }
112:
113:            public PrintWriter getWriter() throws IOException {
114:                if (writer == null) {
115:                    writer = new NSPrintWriter(stringWriter);
116:                }
117:
118:                return writer;
119:            }
120:
121:            public void sendError(int sc) throws IOException {
122:                status = sc;
123:            }
124:
125:            public void sendError(int sc, String msg) throws IOException {
126:                status = sc;
127:                sendBodyText(msg);
128:            }
129:
130:            public void sendRedirect(String location) throws IOException {
131:                setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
132:                this .location = makeAbsolute(location);
133:            }
134:
135:            public void setContentLength(int len) {
136:                throw new UnsupportedOperationException(
137:                        "setContentLength is not available to JSP providers");
138:            }
139:
140:            public void setContentType(String type) {
141:                // We do not support setting the content type of a provider
142:                // However, the JSP compiler generated code calls this, so we have
143:                // to silently ignore it rather than throwing an exception
144:            }
145:
146:            public boolean containsHeader(String name) {
147:                throw new UnsupportedOperationException(headerMsg);
148:            }
149:
150:            public void setDateHeader(String name, long date) {
151:                throw new UnsupportedOperationException(headerMsg);
152:            }
153:
154:            public void addDateHeader(String name, long value) {
155:                throw new UnsupportedOperationException(headerMsg);
156:            }
157:
158:            public void setHeader(String name, String value) {
159:                throw new UnsupportedOperationException(headerMsg);
160:            }
161:
162:            public void addHeader(String name, String value) {
163:                servletResponse.addHeader(name, value);
164:            }
165:
166:            public void setIntHeader(String name, int value) {
167:                throw new UnsupportedOperationException(headerMsg);
168:            }
169:
170:            public void addIntHeader(String name, int value) {
171:                throw new UnsupportedOperationException(headerMsg);
172:            }
173:
174:            public void setStatus(int status) {
175:                this .status = status;
176:            }
177:
178:            public int getStatus() {
179:                return status;
180:            }
181:
182:            public void setBufferSize(int size) {
183:                return;
184:            }
185:
186:            public int getBufferSize() {
187:                return -1;
188:            }
189:
190:            public void reset() throws IllegalStateException {
191:                //out.reset();
192:                stringWriter = new NSStringWriter(4096);
193:            }
194:
195:            public boolean isCommitted() {
196:                return false;
197:            }
198:
199:            public void flushBuffer() throws IOException {
200:                return;
201:            }
202:
203:            public void setLocale(Locale loc) {
204:                return;
205:            }
206:
207:            public Locale getLocale() {
208:                return null;
209:            }
210:
211:            /**
212:             *
213:             * @deprecated
214:             */
215:
216:            public void setStatus(int sc, String msg) {
217:                setStatus(sc);
218:            }
219:
220:            private String makeAbsolute(String location) {
221:                URL url = null;
222:                try {
223:                    // Try making a URL out of the location
224:                    // Throws an exception if the location is relative
225:                    url = new URL(location);
226:                } catch (MalformedURLException e) {
227:                    try {
228:                        url = null == location ? new URL(context
229:                                .getDesktopURL(request)) : new URL(new URL(
230:                                context.getRequestServer(request).toString()),
231:                                location);
232:                    } catch (MalformedURLException ignored) {
233:                        // Give up
234:                        return location;
235:                    }
236:                }
237:                return url.toString();
238:            }
239:
240:            private void sendBodyText(String s) throws IOException {
241:                try {
242:                    PrintWriter out = getWriter();
243:                    out.print(s);
244:                } catch (IllegalStateException ise) {
245:                    ServletOutputStream out = getOutputStream();
246:                    out.print(s);
247:                }
248:            }
249:
250:            private void close() throws IOException {
251:                try {
252:                    PrintWriter out = getWriter();
253:                    out.close();
254:                } catch (IllegalStateException ise) {
255:                    ServletOutputStream out = getOutputStream();
256:                    out.close();
257:                }
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.