HDIV API 2.0.4

org.hdiv.util
Class RequestUtilsHDIV

java.lang.Object
  extended by org.hdiv.util.RequestUtilsHDIV

public class RequestUtilsHDIV
extends java.lang.Object

General purpose utility methods related to processing a servlet request.

Since:
HDIV 2.0
Author:
Gorka Vicente

Constructor Summary
RequestUtilsHDIV()
           
 
Method Summary
static java.lang.String addHDIVParameterIfNecessary(javax.servlet.http.HttpServletRequest request, java.lang.String url)
          Adds HDIV state as a parameter if url references our application.
static java.lang.String addHDIVParameterIfNecessary(javax.servlet.http.HttpServletRequest request, java.lang.String url, boolean prependServletContext)
          Adds HDIV state as a parameter if url references our application.
static java.lang.String addHDIVState(org.hdiv.dataComposer.IDataComposer dataComposer, java.lang.String encodedURL, java.lang.String anchor)
          Adds the HDIV parameter, depending on the strategu defined by the user, to validate the request encodedURL.
static java.lang.String composeAction(java.lang.String url, int questionIndex, java.lang.String charEncoding, org.hdiv.dataComposer.IDataComposer dataComposer)
           It generates a new encoded values for the url parameters.
static java.lang.String composeURL(javax.servlet.http.HttpServletRequest request, java.lang.String finalLocation)
          It creates a new state to store all the parameters and values of the request and it generates a new encoded values for the request parameters and adds the HDIV parameter.
static java.lang.String getContextRelativePath(javax.servlet.ServletRequest request, java.lang.String relativePath)
           
static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)
          Retrieves the current request servlet path.
static boolean hasActionOrServletExtension(java.lang.String path, org.apache.struts2.dispatcher.mapper.ActionMapper actionMapper)
          Checks if path has an action extension or a jsp page extension.
static boolean isContextRelativePath(javax.servlet.ServletRequest request, java.lang.String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestUtilsHDIV

public RequestUtilsHDIV()
Method Detail

addHDIVParameterIfNecessary

public static java.lang.String addHDIVParameterIfNecessary(javax.servlet.http.HttpServletRequest request,
                                                           java.lang.String url,
                                                           boolean prependServletContext)
Adds HDIV state as a parameter if url references our application.

Parameters:
request - HTTP request
url - URL
prependServletContext - true to prepend the location with the servlet context path, false otherwise
Returns:
url with the HDIV state added as a new parameter

addHDIVParameterIfNecessary

public static java.lang.String addHDIVParameterIfNecessary(javax.servlet.http.HttpServletRequest request,
                                                           java.lang.String url)
Adds HDIV state as a parameter if url references our application.

Parameters:
request - HTTP request
url - URL
Returns:
url with the HDIV state added as a new parameter

composeURL

public static java.lang.String composeURL(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String finalLocation)
It creates a new state to store all the parameters and values of the request and it generates a new encoded values for the request parameters and adds the HDIV parameter.

Parameters:
request - HTTP request
finalLocation - the location to redirect to
Returns:
URL with encoded parameters and HDIV parameter

composeAction

public static java.lang.String composeAction(java.lang.String url,
                                             int questionIndex,
                                             java.lang.String charEncoding,
                                             org.hdiv.dataComposer.IDataComposer dataComposer)

It generates a new encoded values for the url parameters.

The returned values guarantees the confidentiality in the encoded and memory strategies if confidentiality indicator defined by user is true.

Parameters:
url - request url
questionIndex - index of the first question occurrence in url string
charEncoding - character encoding
Returns:
url with encoded values

addHDIVState

public static java.lang.String addHDIVState(org.hdiv.dataComposer.IDataComposer dataComposer,
                                            java.lang.String encodedURL,
                                            java.lang.String anchor)
Adds the HDIV parameter, depending on the strategu defined by the user, to validate the request encodedURL.

Parameters:
dataComposer - HDIV's data composer
encodedURL - URL encoded
anchor - anchor
Returns:
url with the HDIV state added as a new parameter
See Also:
org.hdiv.composer.IDataComposer

hasActionOrServletExtension

public static boolean hasActionOrServletExtension(java.lang.String path,
                                                  org.apache.struts2.dispatcher.mapper.ActionMapper actionMapper)
Checks if path has an action extension or a jsp page extension.

Parameters:
path - path
actionMapper - action mapper
Returns:
True if path is an action or references a jsp page.

isContextRelativePath

public static boolean isContextRelativePath(javax.servlet.ServletRequest request,
                                            java.lang.String path)

getContextRelativePath

public static java.lang.String getContextRelativePath(javax.servlet.ServletRequest request,
                                                      java.lang.String relativePath)

getServletPath

public static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest request)
Retrieves the current request servlet path. Deals with differences between servlet specs (2.2 vs 2.3+)

Parameters:
request - the request
Returns:
the servlet path

HDIV 2.0.4

Copyright © 2008 hdiv.org. All Rights Reserved.