Source Code Cross Referenced for TomcatWebPageBinaryServlet.java in  » Workflow-Engines » JFolder » org » jfolder » platforms » servers » instances » tomcat » 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 » Workflow Engines » JFolder » org.jfolder.platforms.servers.instances.tomcat 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.platforms.servers.instances.tomcat;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.io.InputStream;
013:        import java.io.OutputStream;
014:        import java.io.PrintWriter;
015:        import javax.servlet.RequestDispatcher;
016:        import javax.servlet.ServletContext;
017:        import javax.servlet.ServletException;
018:        import javax.servlet.http.HttpServlet;
019:        import javax.servlet.http.HttpServletRequest;
020:        import javax.servlet.http.HttpServletResponse;
021:        import javax.servlet.http.HttpSession;
022:        import javax.servlet.jsp.PageContext;
023:        import javax.xml.parsers.ParserConfigurationException;
024:        import org.xml.sax.SAXException;
025:
026:        //project specific classes
027:        import org.jfolder.common.StandardDataTypes;
028:        import org.jfolder.common.UnexpectedSystemException;
029:        import org.jfolder.common.files.WebPageTagMacro;
030:        import org.jfolder.common.files.WebPageTagMacroHelper;
031:        import org.jfolder.common.function.BaseWebPageTag;
032:        import org.jfolder.common.function.ReturnValueAndClassForWebPageTagContext;
033:        import org.jfolder.common.function.WebPageTagPreferences;
034:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
035:        import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
036:        import org.jfolder.common.tagging.ConceptTagFlagsHelper;
037:        import org.jfolder.common.tagging.ConceptTagHelper;
038:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
039:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
040:        import org.jfolder.common.tagging.ReturnableConceptTag;
041:        import org.jfolder.common.tagging.RootConceptTagHolder;
042:        import org.jfolder.common.tagging.ValueAndClassForConceptTag;
043:        import org.jfolder.common.utils.misc.MiscHelper;
044:        import org.jfolder.common.utils.web.WebComponentHolder;
045:        import org.jfolder.platforms.stores.base.ApplicationDataSourceResolver;
046:        import org.jfolder.platforms.stores.base.SystemStoreFactory;
047:        import org.jfolder.platforms.stores.base.SystemStoreSessionManager;
048:        import org.jfolder.platforms.stores.base.SystemStoreSessionWithinWebPage;
049:        import org.jfolder.web.page.BinaryOutputFromWebPageTag;
050:        import org.jfolder.web.page.RootWebPageTag;
051:
052:        //other classes
053:
054:        public class TomcatWebPageBinaryServlet extends HttpServlet {
055:
056:            public TomcatWebPageBinaryServlet() {
057:            }
058:
059:            public void service(HttpServletRequest inRequest,
060:                    HttpServletResponse inResponse) throws IOException,
061:                    ServletException {
062:
063:                //PrintWriter pw = inResponse.getWriter();
064:                //pw.println("<html><body>TomcatWebPageServlet</body></html>");
065:                //pw.flush();
066:                //pw.close();
067:
068:                //declare session
069:                HttpSession hs = inRequest.getSession();
070:
071:                //application
072:                String destination = inRequest.getServletPath();
073:                //if (destination.startsWith("/")) {
074:                //    destination = destination.substring(1);
075:                //}
076:                if (destination.endsWith("/")) {
077:                    //
078:                    destination = destination.substring(0,
079:                            destination.length() - 1);
080:                }
081:                //destination
082:                //String servletPath = inRequest.getContextPath();
083:                //if (servletPath.startsWith("/")) {
084:                //    servletPath = servletPath.substring(1);
085:                //}
086:                //if (servletPath.endsWith("/")) {
087:                //    servletPath =
088:                //        servletPath.substring(0, servletPath.length() - 1);
089:                //}
090:
091:                //MiscHelper.println("About to dispatch to parent.jsp");
092:                //inResponse.setContentType("text/html");
093:                //
094:                //String destinationPage =
095:                //    (new TomcatServer()).getRelativeWebPageLocation(destination);
096:                RootWebPageTag localRwpt = getBinaryRcth(destination,
097:                        getServletContext());
098:                //
099:                ConceptTagCharacteristicHolder rootCtcharh = localRwpt
100:                        .getFirstChild();
101:                WebPageTagPreferences rootWptp = (WebPageTagPreferences) rootCtcharh
102:                        .getPreferences();
103:                BinaryOutputFromWebPageTag rootBofwpt = ((BinaryOutputFromWebPageTag) rootCtcharh
104:                        .getConceptTag());
105:                //
106:                WebComponentHolder rootWch = WebComponentHolder.newInstance(
107:                        getServletContext(), inRequest, inResponse, inRequest
108:                                .getSession());
109:                DetermineValueAndClassConceptTagContext dvacctc = ReturnValueAndClassForWebPageTagContext
110:                        .newInstance(rootWptp, rootWch);
111:                //
112:                process(rootBofwpt, inResponse, dvacctc);
113:                //
114:                //RequestDispatcher rd =
115:                //    inRequest.getRequestDispatcher(destinationPage);
116:                //rd.include(inRequest, inResponse);
117:                //MiscHelper.println("Finished to dispatch to parent.jsp");
118:            }
119:
120:            //
121:            private final static void process(
122:                    BinaryOutputFromWebPageTag inBofwpt,
123:                    HttpServletResponse inResponse,
124:                    DetermineValueAndClassConceptTagContext inDvacctc)
125:                    throws IOException {
126:                //
127:                try {
128:                    //
129:                    String mimeType = inBofwpt.getMimeType();
130:                    inResponse.setContentType(mimeType);
131:                    //
132:                    byte output[] = inBofwpt.determineBinaryOutput(inDvacctc);
133:                    //
134:                    OutputStream os = inResponse.getOutputStream();
135:                    os.write(output);
136:                    os.flush();
137:                    os.close();
138:                    //
139:
140:                } catch (DetermineValueAndClassConceptTagException inDvaccte) {
141:                    MiscHelper.writeMessage(TomcatWebPageBinaryServlet.class,
142:                            inDvaccte);
143:                    throw new UnexpectedSystemException(inDvaccte);
144:                }
145:            }
146:
147:            //
148:            //
149:            //
150:            //
151:            public final static RootWebPageTag getBinaryRcth(String inPath,
152:                    ServletContext inSc) {
153:
154:                try {
155:                    //
156:                    RootWebPageTag outValue = null;
157:                    //
158:                    //
159:                    //ServletContext sc = pc.getServletContext();
160:
161:                    ApplicationDataSourceResolver adsr = SystemStoreFactory
162:                            .getApplicationDataSourceResolver();
163:                    String macroLocation = adsr
164:                            .getActualWebTemplateLocation(inPath);
165:                    //
166:                    //
167:                    InputStream is = inSc.getResourceAsStream(macroLocation);
168:                    byte webMacroByteContent[] = MiscHelper
169:                            .fromInputStreamToBytesWithoutClose(is);
170:                    String webMacroContent = MiscHelper
171:                            .fromBytesToString(webMacroByteContent);
172:                    is.close();
173:                    //
174:                    RootConceptTagHolder localRcth = BaseWebPageTag
175:                            .getCachedRcth(
176:                                    webMacroContent,
177:                                    WebPageTagPreferences.DEFAULT_ROOT_CONCEPT_TAG_CLASS_NAME);
178:                    Object o = (localRcth.getFirstChildConceptTag());
179:                    //
180:                    //
181:                    outValue = ((RootWebPageTag) o);
182:                    //
183:                    //
184:                    return outValue;
185:                }
186:                //catch (DetermineValueAndClassConceptTagException dvaccte) {
187:                //    inDvacctc.setDetermineException(dvaccte);
188:                //}
189:                catch (IOException ioe) {
190:                    throw new UnexpectedSystemException(ioe);
191:                } catch (ParserConfigurationException pce) {
192:                    throw new UnexpectedSystemException(pce);
193:                } catch (SAXException saxe) {
194:                    throw new UnexpectedSystemException(saxe);
195:                }
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.