Source Code Cross Referenced for ResponderLIB.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » servlets » responders » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.servlets.responders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * ResponderLIB.java
003:         *****************************************************************************/package org.openlaszlo.servlets.responders;
004:
005:        import java.io.*;
006:        import java.util.Properties;
007:        import javax.servlet.ServletConfig;
008:        import javax.servlet.ServletException;
009:        import javax.servlet.http.HttpServletRequest;
010:        import javax.servlet.http.HttpServletResponse;
011:        import org.openlaszlo.utils.LZHttpUtils;
012:        import javax.servlet.ServletOutputStream;
013:        import org.openlaszlo.cache.MediaCache;
014:        import org.openlaszlo.cache.RequestCache;
015:        import org.openlaszlo.server.LPS;
016:        import org.openlaszlo.utils.FileUtils;
017:        import org.openlaszlo.media.MimeType;
018:
019:        import org.apache.log4j.Logger;
020:
021:        /**
022:         * Respond to library requests.
023:         * Currently does not use compilation manager, just looks for and returns
024:         * the requested swf file specified by the 'libpath' query arg.
025:         */
026:
027:        public final class ResponderLIB extends Responder {
028:            private static Logger mLogger = Logger
029:                    .getLogger(ResponderLIB.class);
030:
031:            public int getMimeType() {
032:                return MIME_TYPE_SWF;
033:            }
034:
035:            public void init(String reqName, ServletConfig config,
036:                    Properties prop) throws ServletException, IOException {
037:                super .init(reqName, config, prop);
038:            }
039:
040:            /**
041:             * Delivers a 'snippet' compiled library file. 
042:             *
043:             * Gets the filename of the snippet we are loading from the
044:             * request, where it is specified in the "libpath" query
045:             * arg. 'libpath' is relative to the app base filename.  Thus, an
046:             * app at /intl2/test/snippets/main.lzx, which has &ltimport
047:             * href="lib/foo.lzx"> will send a request with
048:             * lzt=lib&libpath=lib/foo.lzx
049:             */
050:            protected void respondImpl(HttpServletRequest req,
051:                    HttpServletResponse res) throws IOException {
052:
053:                try {
054:                    String patharg = req.getParameter("libpath");
055:                    if (patharg == null) {
056:                        throw new IOException(
057:                        /* (non-Javadoc)
058:                         * @i18n.test
059:                         * @org-mes="could not find 'libpath' query arg in lzt=lib request"
060:                         */
061:                        org.openlaszlo.i18n.LaszloMessages.getMessage(
062:                                ResponderLIB.class.getName(), "051018-71"));
063:                    }
064:
065:                    /* getContextPath() = /intl2
066:                       getPathInfo() = null
067:                       getPathTranslated() = null
068:                       getRequestURI() = /intl2/test/snippets/main.lzx
069:                       getServletPath() = /test/snippets/main.lzx
070:                     */
071:
072:                    ServletOutputStream out = res.getOutputStream();
073:                    PrintWriter p = new PrintWriter(out);
074:
075:                    // canonicalize the separator char
076:                    String path = (new File(patharg)).getPath();
077:                    String appbasedir = (new File(req.getServletPath()))
078:                            .getParent();
079:                    String libpath;
080:                    // Check if we are merging with an absolute or relative lib path.
081:                    // Why doesn't Java have fs:merge-pathnames? 
082:                    if (path.charAt(0) == File.separatorChar) {
083:                        libpath = path;
084:                    } else {
085:                        libpath = (new File(appbasedir, path)).getPath();
086:                    }
087:                    String filename = LZHttpUtils
088:                            .getRealPath(mContext, libpath);
089:                    mLogger.info(
090:                    /* (non-Javadoc)
091:                     * @i18n.test
092:                     * @org-mes="Responding with LIB for " + p[0]
093:                     */
094:                    org.openlaszlo.i18n.LaszloMessages.getMessage(
095:                            ResponderLIB.class.getName(), "051018-104",
096:                            new Object[] { filename }));
097:                    res.setContentType(MimeType.SWF);
098:                    InputStream ins = null;
099:                    try {
100:                        // open the file and return it.
101:                        ins = new BufferedInputStream(new FileInputStream(
102:                                filename));
103:                        FileUtils.send(ins, out);
104:                    } finally {
105:                        FileUtils.close(out);
106:                        FileUtils.close(ins);
107:                    }
108:                } catch (java.io.FileNotFoundException e) {
109:                    throw new IOException(e.getMessage());
110:                }
111:            }
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.