Source Code Cross Referenced for ServletFns.java in  » Ajax » zk » org » zkoss » web » fn » 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 » zk » org.zkoss.web.fn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ServletFns.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Mon Apr 11 15:13:44     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.web.fn;
020:
021:        import java.io.Writer;
022:        import java.io.IOException;
023:        import java.io.UnsupportedEncodingException;
024:
025:        import javax.servlet.ServletContext;
026:        import javax.servlet.ServletRequest;
027:        import javax.servlet.ServletResponse;
028:        import javax.servlet.ServletException;
029:
030:        import org.zkoss.web.servlet.Servlets;
031:        import org.zkoss.web.servlet.http.Encodes;
032:        import org.zkoss.web.servlet.dsp.action.ActionContext;
033:        import org.zkoss.web.servlet.xel.RequestContext;
034:        import org.zkoss.web.servlet.xel.RequestContexts;
035:
036:        /**
037:         * Providing servlet relevant functions for EL.
038:         *
039:         * @author tomyeh
040:         */
041:        public class ServletFns {
042:            protected ServletFns() {
043:            }
044:
045:            /** Encodes a URL.
046:             *
047:             * <p>If an URI contains "*", it will be replaced with a proper Locale.
048:             * For example, if the current Locale is zh_TW and the resource is
049:             * named "ab*.cd", then it searches "ab_zh_TW.cd", "ab_zh.cd" and
050:             * then "ab.cd", until any of them is found.
051:             *
052:             * <blockquote>Note: "*" must be right before ".", or the last character.
053:             * For example, "ab*.cd" and "ab*" are both correct, while
054:             * "ab*cd" and "ab*\/cd" are ignored.</blockquote>
055:             *
056:             * <p>If an URI contains two "*", the first "*" will be replaced with
057:             * a browser code and the second with a proper locale.
058:             * The browser code depends on what browser
059:             * the user are used to visit the web site.
060:             * Currently, the code for Internet Explorer is "ie", Safari is "saf",
061:             * Opera is "opr" and all others are "moz".
062:             * Thus, in the above example, if the resource is named "ab**.cd"
063:             * and Firefox is used, then it searches "abmoz_zh_TW.cd", "abmoz_zh.cd"
064:             * and then "abmoz.cd", until any of them is found.
065:             */
066:            public static String encodeURL(String uri) throws ServletException {
067:                return Encodes.encodeURL(getCurrentServletContext(),
068:                        getCurrentRequest(), getCurrentResponse(), uri);
069:            }
070:
071:            /** Returns whether the browser of the current request is Explorer.
072:             */
073:            public static boolean isExplorer() {
074:                return Servlets.isExplorer(getCurrentRequest());
075:            }
076:
077:            /** Returns whether the browser of the current request is Explorer 7 or later.
078:             */
079:            public static boolean isExplorer7() {
080:                return Servlets.isExplorer7(getCurrentRequest());
081:            }
082:
083:            /** Returns whether the browser of the current request is Gecko based,
084:             * such as Mozilla, Firefox and Camino.
085:             */
086:            public static boolean isGecko() {
087:                return Servlets.isGecko(getCurrentRequest());
088:            }
089:
090:            /** Returns whether the browser of the current request is Safari.
091:             */
092:            public static boolean isSafari() {
093:                return Servlets.isSafari(getCurrentRequest());
094:            }
095:
096:            /** Returns whether the browser of the current request is Opera.
097:             */
098:            public static boolean isOpera() {
099:                return Servlets.isOpera(getCurrentRequest());
100:            }
101:
102:            /** Returns the current EL context. */
103:            public static RequestContext getCurrentContext() {
104:                return RequestContexts.getCurrent();
105:            }
106:
107:            /** Returns the current output. */
108:            public static Writer getCurrentOut() throws IOException {
109:                return getCurrentContext().getOut();
110:            }
111:
112:            /** Returns the current servlet context, or null if not available. */
113:            public static ServletContext getCurrentServletContext() {
114:                return getCurrentContext().getServletContext();
115:            }
116:
117:            /** Returns the current servlet request, or null if not available. */
118:            public static ServletRequest getCurrentRequest() {
119:                return getCurrentContext().getRequest();
120:            }
121:
122:            /** Returns the current servlet response, or null if not available. */
123:            public static ServletResponse getCurrentResponse() {
124:                return getCurrentContext().getResponse();
125:            }
126:
127:            /** Renders the DSP fragment from EL.
128:             *
129:             * @param ac the action context; never null.
130:             */
131:            public static void render(ActionContext ac)
132:                    throws ServletException, IOException {
133:                ac.renderFragment(null);
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.