Java Doc for CmsRequestUtil.java in  » Content-Management-System » opencms » org » opencms » util » 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 » Content Management System » opencms » org.opencms.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.opencms.util.CmsRequestUtil

CmsRequestUtil
final public class CmsRequestUtil (Code)
Provides utility functions for dealing with values a HttpServletRequest .


author:
   Alexander Kandzior
version:
   $Revision: 1.27 $
since:
   6.0.0



Field Summary
final public static  StringATTRIBUTE_ERRORCODE
     Request attribute that contains the original error code.
final public static  StringHEADER_ACCEPT_CHARSET
     HTTP Accept-Charset Header for internal requests used during static export.
final public static  StringHEADER_ACCEPT_LANGUAGE
     HTTP Accept-Language Header for internal requests used during static export.
final public static  StringHEADER_CACHE_CONTROL
     HTTP Header "Cache-Control".
final public static  StringHEADER_CONNECTION
     HTTP Header "Connection".
final public static  StringHEADER_CONTENT_DISPOSITION
     The "Content-Disposition" http header.
final public static  StringHEADER_CONTENT_TYPE
     The "Content-Type" http header.
final public static  StringHEADER_EXPIRES
     HTTP Header "Expires".
final public static  StringHEADER_IF_MODIFIED_SINCE
     HTTP Header "If-Modified-Since".
final public static  StringHEADER_JSESSIONID
     The Header that stores the session id (used by OpenCms upload applet).
final public static  StringHEADER_LAST_MODIFIED
     HTTP Header "Last-Modified".
final public static  StringHEADER_LOCATION
     HTTP Header "Location".
final public static  StringHEADER_OPENCMS_EXPORT
     HTTP Header for internal requests used during static export.
final public static  StringHEADER_PRAGMA
     HTTP Header "Pragma".
final public static  StringHEADER_SERVER
     HTTP Header "Server".
final public static  StringHEADER_USER_AGENT
     HTTP Header "user-agent".
final public static  StringHEADER_VALUE_MAX_AGE
     HTTP Header value "max-age=" (for "Cache-Control").
final public static  StringHEADER_VALUE_MUST_REVALIDATE
     HTTP Header value "must-revalidate" (for "Cache-Control").
final public static  StringHEADER_VALUE_NO_CACHE
     HTTP Header value "no-cache" (for "Cache-Control").
final public static  StringHEADER_WWW_AUTHENTICATE
     HTTP Header "WWW-Authenticate".
final public static  StringHEADER_X_FORWARDED_FOR
     Identifier for x-forwarded-for (i.e.
final public static  StringPARAMETER_ASSIGNMENT
     Assignment char between parameter name and values.
final public static  StringPARAMETER_DELIMITER
     Delimiter char between parameters.
final public static  StringURL_DELIMITER
     Delimiter char between url and query.


Method Summary
public static  StringappendParameter(String url, String paramName, String paramValue)
    
public static  StringappendParameters(String url, Map params, boolean encode)
    
public static  MapcreateParameterMap(Map params)
    
public static  MapcreateParameterMap(String query)
     Parses the parameters of the given request query part and creates a parameter map out of them.

Please note: This does not parse a full request URI/URL, only the query part that starts after the "?".

public static  StringencodeParams(HttpServletRequest req)
     Returns all parameters of the given request as a request parameter URL String, that is in the form key1=value1&key2=value2 etc.
public static  StringencodeParamsWithUri(String uri, HttpServletRequest req)
    
public static  voidforwardRequest(String target, HttpServletRequest req, HttpServletResponse res)
     Forwards the response to the given target, which may contain parameters appended like for example ?a=b&c=d.

Please note: If possible, use CmsRequestUtil.forwardRequest(String,Map,HttpServletRequest,HttpServletResponse) where the parameters are passed as a map, since the parsing of the parameters may introduce issues with encoding and is in general much less effective.

The parsing of parameters will likely fail for "large values" (e.g.

public static  voidforwardRequest(String target, Map params, HttpServletRequest req, HttpServletResponse res)
     Forwards the response to the given target, with the provided parameter map.

The target URI must NOT have parameters appended like for example ?a=b&c=d. The values in the provided map must be of type String[].

public static  StringgetCookieValue(CmsJspActionElement jsp, String name)
    
public static  StringgetNotEmptyDecodedParameter(HttpServletRequest request, String paramName)
    
public static  StringgetNotEmptyParameter(HttpServletRequest request, String paramName)
    
public static  ObjectgetSessionValue(HttpServletRequest request, String key)
     Reads an object from the session of the given HTTP request.

A session will be initialized if the request does not currently have a session.

public static  ListreadMultipartFileItems(HttpServletRequest request)
     Parses a request of the form multipart/form-data.
public static  MapreadParameterMapFromMultiPart(String encoding, List multiPartFileItems)
    
public static  voidredirectPermanently(CmsJspActionElement jsp, String target)
    
public static  voidredirectRequestSecure(CmsJspActionElement jsp, String target)
    
public static  voidremoveSessionValue(HttpServletRequest request, String key)
     Removes an object from the session of the given http request.

A session will be initialized if the request does not currently have a session.

public static  voidsetCookieValue(CmsJspActionElement jsp, String name, String value)
     Sets the value of a specific cookie.

If no cookie exists with the value, a new cookie will be created.

public static  voidsetNoCacheHeaders(HttpServletResponse res)
    
public static  voidsetSessionValue(HttpServletRequest request, String key, Object value)
     Adds an object to the session of the given HTTP request.

A session will be initialized if the request does not currently have a session.


Field Detail
ATTRIBUTE_ERRORCODE
final public static String ATTRIBUTE_ERRORCODE(Code)
Request attribute that contains the original error code.



HEADER_ACCEPT_CHARSET
final public static String HEADER_ACCEPT_CHARSET(Code)
HTTP Accept-Charset Header for internal requests used during static export.



HEADER_ACCEPT_LANGUAGE
final public static String HEADER_ACCEPT_LANGUAGE(Code)
HTTP Accept-Language Header for internal requests used during static export.



HEADER_CACHE_CONTROL
final public static String HEADER_CACHE_CONTROL(Code)
HTTP Header "Cache-Control".



HEADER_CONNECTION
final public static String HEADER_CONNECTION(Code)
HTTP Header "Connection".



HEADER_CONTENT_DISPOSITION
final public static String HEADER_CONTENT_DISPOSITION(Code)
The "Content-Disposition" http header.



HEADER_CONTENT_TYPE
final public static String HEADER_CONTENT_TYPE(Code)
The "Content-Type" http header.



HEADER_EXPIRES
final public static String HEADER_EXPIRES(Code)
HTTP Header "Expires".



HEADER_IF_MODIFIED_SINCE
final public static String HEADER_IF_MODIFIED_SINCE(Code)
HTTP Header "If-Modified-Since".



HEADER_JSESSIONID
final public static String HEADER_JSESSIONID(Code)
The Header that stores the session id (used by OpenCms upload applet).



HEADER_LAST_MODIFIED
final public static String HEADER_LAST_MODIFIED(Code)
HTTP Header "Last-Modified".



HEADER_LOCATION
final public static String HEADER_LOCATION(Code)
HTTP Header "Location".



HEADER_OPENCMS_EXPORT
final public static String HEADER_OPENCMS_EXPORT(Code)
HTTP Header for internal requests used during static export.



HEADER_PRAGMA
final public static String HEADER_PRAGMA(Code)
HTTP Header "Pragma".



HEADER_SERVER
final public static String HEADER_SERVER(Code)
HTTP Header "Server".



HEADER_USER_AGENT
final public static String HEADER_USER_AGENT(Code)
HTTP Header "user-agent".



HEADER_VALUE_MAX_AGE
final public static String HEADER_VALUE_MAX_AGE(Code)
HTTP Header value "max-age=" (for "Cache-Control").



HEADER_VALUE_MUST_REVALIDATE
final public static String HEADER_VALUE_MUST_REVALIDATE(Code)
HTTP Header value "must-revalidate" (for "Cache-Control").



HEADER_VALUE_NO_CACHE
final public static String HEADER_VALUE_NO_CACHE(Code)
HTTP Header value "no-cache" (for "Cache-Control").



HEADER_WWW_AUTHENTICATE
final public static String HEADER_WWW_AUTHENTICATE(Code)
HTTP Header "WWW-Authenticate".



HEADER_X_FORWARDED_FOR
final public static String HEADER_X_FORWARDED_FOR(Code)
Identifier for x-forwarded-for (i.e. proxied) request headers.



PARAMETER_ASSIGNMENT
final public static String PARAMETER_ASSIGNMENT(Code)
Assignment char between parameter name and values.



PARAMETER_DELIMITER
final public static String PARAMETER_DELIMITER(Code)
Delimiter char between parameters.



URL_DELIMITER
final public static String URL_DELIMITER(Code)
Delimiter char between url and query.





Method Detail
appendParameter
public static String appendParameter(String url, String paramName, String paramValue)(Code)
Appends a request parameter to the given URL.

This method takes care about the adding the parameter as an additional parameter (appending ¶m=value) or as the first parameter (appending ?param=value).


Parameters:
  url - the URL where to append the parameter to
Parameters:
  paramName - the paramter name to append
Parameters:
  paramValue - the parameter value to append the URL with the given parameter appended




appendParameters
public static String appendParameters(String url, Map params, boolean encode)(Code)
Appends a map of request parameters to the given URL.

The map can contains values of String[] or simple String values.

This method takes care about the adding the parameter as an additional parameter (appending ¶m=value) or as the first parameter (appending ?param=value).


Parameters:
  url - the URL where to append the parameter to
Parameters:
  params - the parameters to append
Parameters:
  encode - if true, the parameter values are encoded before they are appended the URL with the given parameter appended




createParameterMap
public static Map createParameterMap(Map params)(Code)
Creates a valid request parameter map from the given map, most notably changing the values form String to String[] if required.

If the given parameter map is null, then null is returned.


Parameters:
  params - the map of parameters to create a parameter map from the created parameter map, all values will be instances of String[]




createParameterMap
public static Map createParameterMap(String query)(Code)
Parses the parameters of the given request query part and creates a parameter map out of them.

Please note: This does not parse a full request URI/URL, only the query part that starts after the "?". For example, in the URI /system/index.html?a=b&c=d, the query part is a=b&c=d.

If the given String is empty, an empty map is returned.


Parameters:
  query - the query to parse the parameter map created from the query




encodeParams
public static String encodeParams(HttpServletRequest req)(Code)
Returns all parameters of the given request as a request parameter URL String, that is in the form key1=value1&key2=value2 etc. The result will be encoded using the CmsEncoder.encode(String) function.


Parameters:
  req - the request to read the parameters from all initialized parameters of the given request as request parameter URL String




encodeParamsWithUri
public static String encodeParamsWithUri(String uri, HttpServletRequest req)(Code)
Encodes the given URI, with all parameters from the given request appended.

The result will be encoded using the CmsEncoder.encode(String) function.


Parameters:
  req - the request where to read the parameters from
Parameters:
  uri - the URI to encode the encoded URI, with all parameters from the given request appended




forwardRequest
public static void forwardRequest(String target, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException(Code)
Forwards the response to the given target, which may contain parameters appended like for example ?a=b&c=d.

Please note: If possible, use CmsRequestUtil.forwardRequest(String,Map,HttpServletRequest,HttpServletResponse) where the parameters are passed as a map, since the parsing of the parameters may introduce issues with encoding and is in general much less effective.

The parsing of parameters will likely fail for "large values" (e.g. full blown web forms with <textarea> elements etc. Use this method only if you know that the target will just contain up to 3 parameters which are relatively short and have no encoding or line break issues.


Parameters:
  target - the target to forward to (may contain parameters like ?a=b&c=d)
Parameters:
  req - the request to forward
Parameters:
  res - the response to forward
throws:
  IOException - in case the forwarding fails
throws:
  ServletException - in case the forwarding fails




forwardRequest
public static void forwardRequest(String target, Map params, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException(Code)
Forwards the response to the given target, with the provided parameter map.

The target URI must NOT have parameters appended like for example ?a=b&c=d. The values in the provided map must be of type String[]. If required, use CmsRequestUtil.createParameterMap(Map) before calling this method to make sure all values are actually of the required array type.


Parameters:
  target - the target to forward to (may NOT contain parameters like ?a=b&c=d)
Parameters:
  params - the parameter map (the values must be of type String[]
Parameters:
  req - the request to forward
Parameters:
  res - the response to forward
throws:
  IOException - in case the forwarding fails
throws:
  ServletException - in case the forwarding fails




getCookieValue
public static String getCookieValue(CmsJspActionElement jsp, String name)(Code)
Returns the value of the cookie with the given name.


Parameters:
  jsp - the CmsJspActionElement to use
Parameters:
  name - the name of the cookie the value of the cookie with the given name or null, if no cookie exists with the name




getNotEmptyDecodedParameter
public static String getNotEmptyDecodedParameter(HttpServletRequest request, String paramName)(Code)
Reads value from the request parameters, will return null if the value is not available or only white space.

The value of the request will also be decoded using CmsEncoder.decode(String) and also trimmed using String.trim .


Parameters:
  request - the request to read the parameter from
Parameters:
  paramName - the parameter name to read the request parameter value for the given parameter




getNotEmptyParameter
public static String getNotEmptyParameter(HttpServletRequest request, String paramName)(Code)
Reads value from the request parameters, will return null if the value is not available or only white space.


Parameters:
  request - the request to read the parameter from
Parameters:
  paramName - the parameter name to read the request parameter value for the given parameter




getSessionValue
public static Object getSessionValue(HttpServletRequest request, String key)(Code)
Reads an object from the session of the given HTTP request.

A session will be initialized if the request does not currently have a session. As a result, the request will always have a session after this method has been called.

Will return null if no corresponding object is found in the session.


Parameters:
  request - the request to get the session from
Parameters:
  key - the key of the object to read from the session the object received form the session, or null




readMultipartFileItems
public static List readMultipartFileItems(HttpServletRequest request)(Code)
Parses a request of the form multipart/form-data. The result list will contain items of type FileItem . If the request is not of type multipart/form-data, then null is returned.


Parameters:
  request - the HTTP servlet request to parse the list of FileItem extracted from the multipart request,or null if the request was not of type multipart/form-data




readParameterMapFromMultiPart
public static Map readParameterMapFromMultiPart(String encoding, List multiPartFileItems)(Code)
Creates a "standard" request parameter map from the values of a multipart/form-data request.


Parameters:
  encoding - the encoding to use when creating the values
Parameters:
  multiPartFileItems - the list of parsed multi part file items a map containing all non-file request parameters
See Also:   CmsRequestUtil.readMultipartFileItems(HttpServletRequest)




redirectPermanently
public static void redirectPermanently(CmsJspActionElement jsp, String target)(Code)
Redirects the response to the target link using a "301 - Moved Permanently" header.

This implementation will work only on JSP pages in OpenCms that use the default JSP loader implementation.


Parameters:
  jsp - the OpenCms JSP context
Parameters:
  target - the target link




redirectRequestSecure
public static void redirectRequestSecure(CmsJspActionElement jsp, String target) throws IOException(Code)
Redirects the response to the target link.

Use this method instead of javax.servlet.http.HttpServletResponse.sendRedirect(java.lang.String) to avoid relative links with secure sites (and issues with apache).


Parameters:
  jsp - the OpenCms JSP context
Parameters:
  target - the target link
throws:
  IOException - if something goes wrong during redirection




removeSessionValue
public static void removeSessionValue(HttpServletRequest request, String key)(Code)
Removes an object from the session of the given http request.

A session will be initialized if the request does not currently have a session. As a result, the request will always have a session after this method has been called.


Parameters:
  request - the request to get the session from
Parameters:
  key - the key of the object to be removed from the session




setCookieValue
public static void setCookieValue(CmsJspActionElement jsp, String name, String value)(Code)
Sets the value of a specific cookie.

If no cookie exists with the value, a new cookie will be created.
Parameters:
  jsp - the CmsJspActionElement to use
Parameters:
  name - the name of the cookie
Parameters:
  value - the value of the cookie




setNoCacheHeaders
public static void setNoCacheHeaders(HttpServletResponse res)(Code)
Sets headers to the given response to prevent client side caching.

The following headers are set:

Cache-Control: max-age=0
Cache-Control: must-revalidate
Pragma: no-cache

Parameters:
  res - the request where to set the no-cache headers




setSessionValue
public static void setSessionValue(HttpServletRequest request, String key, Object value)(Code)
Adds an object to the session of the given HTTP request.

A session will be initialized if the request does not currently have a session. As a result, the request will always have a session after this method has been called.


Parameters:
  request - the request to get the session from
Parameters:
  key - the key of the object to be stored in the session
Parameters:
  value - the object to be stored in the session




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.