Java Doc for Servlets.java in  » Ajax » zk » org » zkoss » web » servlet » 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.servlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.zkoss.web.servlet.Servlets

All known Subclasses:   org.zkoss.web.servlet.http.Https,
Servlets
public class Servlets (Code)
The servlet relevant utilities.
author:
   tomyeh
See Also:   org.zkoss.web.servlet.http.Https
See Also:   org.zkoss.web.servlet.Charsets


Field Summary
final public static  intAPPEND_PARAM
     Whether to append params if both uri and params contain the same parameter.
final public static  intIGNORE_PARAM
     Whether to ignore params if both uri and params contain the same parameter.
final public static  intOVERWRITE_URI
     Whether to overwrite uri if both uri and params contain the same parameter.
final public static  intPASS_THRU_ATTR
     Whether the specified parameters shall be passed thru the request attribute called arg.

Constructor Summary
protected  Servlets()
     Utilities; no instantiation required.

Method Summary
final public static  ExtendletContextaddExtendletContext(ServletContext ctx, String name, ExtendletContext extctx)
     Adds an extended context.
final public static  voidforward(ServletContext ctx, ServletRequest request, ServletResponse response, String uri, Map params, int mode)
     Forward to the specified URI. It enhances RequestDispatcher in the following ways.
  • It handles "~ctx"" where ctx is the context path of the foreign context.
final public static  voidforward(ServletContext ctx, ServletRequest request, ServletResponse response, String uri)
     A shortcut of forward(request, response, uri, null, 0).
final public static  StringgenerateURI(String uri, Map params, int mode)
     Generates URI by appending the parameters.
final public static  ListgetContextPaths()
     Returns a list of context paths (e.g., "/abc") that this application has.
final public static  ExtendletContextgetExtendletContext(ServletContext ctx, String name)
     Returns the extended context of the specified name.
final public static  StringgetExtension(String path)
     Returns the file extension of the specified path, or null if no extension at all.

Note: the extension is converted to the lower case.

Note: it assumes the session ID, if any, starts with semicolon. For example, the path could be "/a/b.zul;jsession=xxx".
Parameters:
  path - the path.

final public static  StringgetLimitTimeOffer()
     Returns a token to represent a limit-time offer.
final public static  RequestDispatchergetRequestDispatcher(ServletContext ctx, ServletRequest request, String uri, Map params, int mode)
     Returns the request dispatch of the specified URI.
Parameters:
  ctx - the servlet context.
final public static  URLgetResource(ServletContext ctx, String uri)
     Returns the resource of the specified uri.
final public static  InputStreamgetResourceAsStream(ServletContext ctx, String uri)
     Returns the resource stream of the specified uri.
final public static  StringgetUserAgent(ServletRequest req)
     Returns the user-agent header, which indicates what the client is, or an empty string if not available.
final public static  voidinclude(ServletContext ctx, ServletRequest request, ServletResponse response, String uri, Map params, int mode)
     Includes the resource at the specified URI. It enhances RequestDispatcher to allow the inclusion with a parameter map -- acutually converting parameters to a query string and appending it to uri.

NOTE: don't include query parameters in uri.
Parameters:
  ctx - the servlet context.

final public static  voidinclude(ServletContext ctx, ServletRequest request, ServletResponse response, String uri)
     A shortcut of include(request, response, uri, null, 0).
final public static  booleanisExplorer(ServletRequest req)
     Returns whether the browser is Internet Explorer.
final public static  booleanisExplorer7(ServletRequest req)
     Returns whether the browser is Explorer 7 or later.
final public static  booleanisForwarded(ServletRequest request)
     Tests whether this page is forwarded by another page.
final public static  booleanisGecko(ServletRequest req)
    
final public static  booleanisHilDevice(ServletRequest req)
     Returns whether the client is a mobile device supporting HIL (Handset Interactive Language).
final public static  booleanisIncluded(ServletRequest request)
     Tests whether this page is included by another page.
final public static  booleanisMilDevice(ServletRequest req)
     Returns whether the client is a mobile device supporting MIL (Mobile Interactive Language).
final public static  booleanisOfferExpired(String lto, int timeout)
     Returns whether a token returned by getLimitTimeOffer expired.
final public static  booleanisOpera(ServletRequest req)
     Returns whether the browser is Opera.
final public static  booleanisRobot(ServletRequest req)
     Returns whether the client is a robot (such as Web crawlers).
final public static  booleanisSafari(ServletRequest req)
     Returns whether the browser is Safari.
final public static  booleanisServlet23()
     Returns whether the current Web server supports Servlet 2.3 or above.
final public static  booleanisServlet24()
     Returns whether the current Web server supports Servlet 2.4 or above.
final public static  booleanisUniversalURL(String uri)
    
final public static  Stringlocate(ServletContext ctx, ServletRequest request, String pgpath, Locator locator)
     Locates a page based on the specified Locale.
final public static  ExtendletContextremoveExtendletContext(ServletContext ctx, String name)
     Removes an extended context of the specified name.

Field Detail
APPEND_PARAM
final public static int APPEND_PARAM(Code)
Whether to append params if both uri and params contain the same parameter. In other words, they both appear as the final query string. Used by Servlets.generateURI



IGNORE_PARAM
final public static int IGNORE_PARAM(Code)
Whether to ignore params if both uri and params contain the same parameter. Used by Servlets.generateURI



OVERWRITE_URI
final public static int OVERWRITE_URI(Code)
Whether to overwrite uri if both uri and params contain the same parameter. Used by Servlets.generateURI



PASS_THRU_ATTR
final public static int PASS_THRU_ATTR(Code)
Whether the specified parameters shall be passed thru the request attribute called arg.




Constructor Detail
Servlets
protected Servlets()(Code)
Utilities; no instantiation required.




Method Detail
addExtendletContext
final public static ExtendletContext addExtendletContext(ServletContext ctx, String name, ExtendletContext extctx)(Code)
Adds an extended context. the previous extended context, if any, associated withthe specified name.



forward
final public static void forward(ServletContext ctx, ServletRequest request, ServletResponse response, String uri, Map params, int mode) throws IOException, ServletException(Code)
Forward to the specified URI. It enhances RequestDispatcher in the following ways.
  • It handles "~ctx"" where ctx is the context path of the foreign context. It is called foriegn URI.
  • It detects whether the page calling this method is included by another servlet/page. If so, it uses RequestDispatcher.include() instead of RequestDispatcher.forward().
  • The forwarded page could accept additional parameters -- acutually converting parameters to a query string and appending it to uri.
  • In additions, it does HTTP encoding, i.e., converts '+' and other characters to comply HTTP.

NOTE: don't include query parameters in uri.
Parameters:
  ctx - the servlet context. If null, uri cannot be foreign URI.It is ignored if URI is relevant (neither starts with '/' nor '~').
Parameters:
  uri - the URI to include. It is OK to relevant (without leading'/'). If starts with "/", the context path of request is assumed.To reference to foreign context, use "~ctx" where ctx is thecontext path of the foreign context (without leading '/').If it could be any context path recognized by the Web container orany name registered with Servlets.addExtendletContext.
Parameters:
  params - the parameter map; null to ignore
Parameters:
  mode - one of Servlets.OVERWRITE_URI, Servlets.IGNORE_PARAM,and Servlets.APPEND_PARAM. It defines how to handle if both uriand params contains the same parameter.




forward
final public static void forward(ServletContext ctx, ServletRequest request, ServletResponse response, String uri) throws IOException, ServletException(Code)
A shortcut of forward(request, response, uri, null, 0).



generateURI
final public static String generateURI(String uri, Map params, int mode)(Code)
Generates URI by appending the parameters. Note: it doesn't support the ~xxx/ format.
Parameters:
  params - the parameters to apend to the query string
Parameters:
  mode - one of Servlets.OVERWRITE_URI, Servlets.IGNORE_PARAM,Servlets.APPEND_PARAM and Servlets.PASS_THRU_ATTR.It defines how to handle if both uri and params contains the sameparameter.mode is used only if both uri contains query string and params isnot empty.
See Also:   Encodes.encodeURL(ServletContextServletRequestServletResponseString)



getContextPaths
final public static List getContextPaths()(Code)
Returns a list of context paths (e.g., "/abc") that this application has. This implementation parse application.xml. For war that doesn't contain application.xml might have to override this method and parse another file to know what context being loaded.



getExtendletContext
final public static ExtendletContext getExtendletContext(ServletContext ctx, String name)(Code)
Returns the extended context of the specified name.



getExtension
final public static String getExtension(String path)(Code)
Returns the file extension of the specified path, or null if no extension at all.

Note: the extension is converted to the lower case.

Note: it assumes the session ID, if any, starts with semicolon. For example, the path could be "/a/b.zul;jsession=xxx".
Parameters:
  path - the path. If path is null, null is returned.
since:
   2.4.1




getLimitTimeOffer
final public static String getLimitTimeOffer()(Code)
Returns a token to represent a limit-time offer. It is mainly used as an parameter value (mostlycalled zk_lto), and then you could verify whether it is expired by Servlets.isOfferExpired .



getRequestDispatcher
final public static RequestDispatcher getRequestDispatcher(ServletContext ctx, ServletRequest request, String uri, Map params, int mode) throws ServletException(Code)
Returns the request dispatch of the specified URI.
Parameters:
  ctx - the servlet context. If null, uri cannot be foreign URI.It is ignored if uri is relevant (neither starts with '/' nor '~').
Parameters:
  request - the request. If null, uri cannot be relevant.It is used only if uri is relevant.
Parameters:
  uri - the URI to include. It is OK to relevant (without leading'/'). If starts with "/", the context path of request is assumed.To reference to foreign context, use "~ctx/" where ctx is thecontext path of the foreign context (without leading '/').
Parameters:
  params - the parameter map; null to ignore
Parameters:
  mode - one of Servlets.OVERWRITE_URI, Servlets.IGNORE_PARAM,and Servlets.APPEND_PARAM. It defines how to handle if both uriand params contains the same parameter.



getResource
final public static URL getResource(ServletContext ctx, String uri) throws MalformedURLException(Code)
Returns the resource of the specified uri. Unlike ServletContext.getResource, it handles "~" like Servlets.getRequestDispatcher did.



getResourceAsStream
final public static InputStream getResourceAsStream(ServletContext ctx, String uri)(Code)
Returns the resource stream of the specified uri. Unlike ServletContext.getResource, it handles "~" like Servlets.getRequestDispatcher did.



getUserAgent
final public static String getUserAgent(ServletRequest req)(Code)
Returns the user-agent header, which indicates what the client is, or an empty string if not available.

Note: it doesn't return null, so it is easy to test what the client is with String.indexOf .
since:
   3.0.2




include
final public static void include(ServletContext ctx, ServletRequest request, ServletResponse response, String uri, Map params, int mode) throws IOException, ServletException(Code)
Includes the resource at the specified URI. It enhances RequestDispatcher to allow the inclusion with a parameter map -- acutually converting parameters to a query string and appending it to uri.

NOTE: don't include query parameters in uri.
Parameters:
  ctx - the servlet context. If null, uri cannot be foreign URI.It is ignored if URI is relevant (neither starts with '/' nor '~').
Parameters:
  uri - the URI to include. It is OK to relevant (without leading'/'). If starts with "/", the context path of request is assumed.To reference to foreign context, use "~ctx/" where ctx is thecontext path of the foreign context (without leading '/').
Parameters:
  params - the parameter map; null to ignore
Parameters:
  mode - one of Servlets.OVERWRITE_URI, Servlets.IGNORE_PARAM,and Servlets.APPEND_PARAM. It defines how to handle if both uriand params contains the same parameter.




include
final public static void include(ServletContext ctx, ServletRequest request, ServletResponse response, String uri) throws IOException, ServletException(Code)
A shortcut of include(request, response, uri, null, 0).



isExplorer
final public static boolean isExplorer(ServletRequest req)(Code)
Returns whether the browser is Internet Explorer. If true, it also implies Servlets.isExplorer7 is true.



isExplorer7
final public static boolean isExplorer7(ServletRequest req)(Code)
Returns whether the browser is Explorer 7 or later.



isForwarded
final public static boolean isForwarded(ServletRequest request)(Code)
Tests whether this page is forwarded by another page.



isGecko
final public static boolean isGecko(ServletRequest req)(Code)
Returns whether the browser is Gecko based, such as Mozilla, Firefox and Camino



isHilDevice
final public static boolean isHilDevice(ServletRequest req)(Code)
Returns whether the client is a mobile device supporting HIL (Handset Interactive Language).

Note: ZK Mobile for Android supports both MIL and HIL. That is, both Servlets.isHilDevice and Servlets.isMilDevice return true.
since:
   3.0.2




isIncluded
final public static boolean isIncluded(ServletRequest request)(Code)
Tests whether this page is included by another page.



isMilDevice
final public static boolean isMilDevice(ServletRequest req)(Code)
Returns whether the client is a mobile device supporting MIL (Mobile Interactive Language).
since:
   2.4.0



isOfferExpired
final public static boolean isOfferExpired(String lto, int timeout)(Code)
Returns whether a token returned by getLimitTimeOffer expired.
Parameters:
  timeout - how long the office shall expire, unit: seconds.



isOpera
final public static boolean isOpera(ServletRequest req)(Code)
Returns whether the browser is Opera.



isRobot
final public static boolean isRobot(ServletRequest req)(Code)
Returns whether the client is a robot (such as Web crawlers).

Because there are too many robots, it returns true if the user-agent is not recognized.




isSafari
final public static boolean isSafari(ServletRequest req)(Code)
Returns whether the browser is Safari.



isServlet23
final public static boolean isServlet23()(Code)
Returns whether the current Web server supports Servlet 2.3 or above. Thus, if Servlets.isServlet24 returns true, Servlets.isServlet23 must return true, too.
since:
   3.0.0



isServlet24
final public static boolean isServlet24()(Code)
Returns whether the current Web server supports Servlet 2.4 or above.
since:
   3.0.0



isUniversalURL
final public static boolean isUniversalURL(String uri)(Code)
Returns whether a URL starts with xxx://, mailto:, about:, javascript:



locate
final public static String locate(ServletContext ctx, ServletRequest request, String pgpath, Locator locator) throws ServletException(Code)
Locates a page based on the specified Locale. It never returns null.

If an URI contains "*", it will be replaced with a proper Locale. For example, if the current Locale is zh_TW and the resource is named "ab*.cd", then it searches "ab_zh_TW.cd", "ab_zh.cd" and then "ab.cd", until any of them is found.

Note: "*" must be right before ".", or the last character. For example, "ab*.cd" and "ab*" are both correct, while "ab*cd" and "ab*\/cd" are ignored.

If an URI contains two "*", the first "*" will be replaced with a browser code and the second with a proper locale. The browser code depends on what browser the user are used to visit the web site. Currently, the code for Internet Explorer is "ie", Safari is "saf", Opera is "opr" and all others are "moz". Thus, in the above example, if the resource is named "ab**.cd" and Firefox is used, then it searches "abmoz_zh_TW.cd", "abmoz_zh.cd" and then "abmoz.cd", until any of them is found.

Note: it assumes the path as name_lang_cn_var.ext where ".ext" is optional. Example, my_zh_tw.html.jsp.

Note: unlike Encodes.encodeURL(ServletContextServletRequestServletResponseString) , it always locates the Locale, without handling "*".
Parameters:
  ctx - the servlet context to locate pages
Parameters:
  pgpath - the page path excluding servlet name. It is OK to havethe query string. It might contain "*" for current browser code and Locale.
Parameters:
  locator - the locator used to locate resource. If null, ctxis assumed. pgpath if the original one matches; others if locale matches;never null




removeExtendletContext
final public static ExtendletContext removeExtendletContext(ServletContext ctx, String name)(Code)
Removes an extended context of the specified name.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.