BEA Systems, Inc.

com.beasys.commerce.axiom.jsp
Class JspHelper

java.lang.Object
  |
  +--com.beasys.commerce.axiom.jsp.JspHelper
Direct Known Subclasses:
P13NJspHelper, PortalAdminHelper

public class JspHelper
extends java.lang.Object
implements JspConstants

A helper class for all JSP pages. Some of these methods assume the you are using the FlowManager model which is highly recommended but not required. Prescribes methods which faciltate p13n run-time operation. Allows access to the FlowManager URI, the application's working directory, the home page, and the current page. Also, facilitates management of the application's run-time session, by providing convenience methods for setting and getting session values, and setting and getting JSP destinations. Implements several constants interface to reduce the burden of constant referencing by JSP pages.


Fields inherited from interface com.beasys.commerce.axiom.jsp.JspConstants
DATE_FORMAT, DEFAULT_DESTINATION, DEFAULT_SUCCESSOR, DESTINATION_URI, IMMUTABLE_SERVICEMANAGER_HOME_PAGE, JSP_CALENDAR_FEATURES, JSP_COMMERCE_CALENDAR_FEATURES, JSP_PORTALS_BASE_DIRECTORY, JSP_TOOLS_ADMIN_HOME, JSP_TOOLS_BASE_DIRECTORY, JSP_TOOLS_DOC_RTR, JSP_TOOLS_GUIDE_FEATURES, JSP_TOOLS_PROPERTYMGMT_ADMIN_HOME, JSP_TOOLS_USERMGMT_ADMIN_HOME, JSP_TOOLS_UTIL_DIRECTORY, P13N_CACHED_REQUEST, P13N_CACHED_SESSION, REPOSITORY_DIR, SERVICEMANAGER_COOKIE_TIMEOUT, SERVICEMANAGER_CURRENT_PAGE, SERVICEMANAGER_HOME_PAGE, SERVICEMANAGER_LOGGED_IN, SERVICEMANAGER_OVERRIDE_BOOK, SERVICEMANAGER_SESSION_TIMEOUT, SERVICEMANAGER_SUCCESSOR, SERVICEMANAGER_USER, SERVLET_CONFIG, TRAFFIC_URI, TRANSACTION_SERVICE, TRANSACTION_TIMEOUT, USER_TRANS_TIMEOUT, WORKING_DIR, WORKING_DIR_FILES
 
Constructor Summary
JspHelper()
           
 
Method Summary
static java.lang.String decode(java.lang.String aString)
          Decodes the provided String using a Base64Decoder.
static java.lang.String encode(java.lang.String aString)
          Encodes the provided String using a Base64Encoder.
static javax.servlet.http.Cookie findCookie(java.lang.String aName, javax.servlet.http.Cookie[] cookies)
          Finds the cookie for a given cookie name.
static int getCookieTimeout(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the p13n app Cookie timeout, in seconds.
static java.lang.String getCookieValue(java.lang.String aName, javax.servlet.http.Cookie[] cookies)
          Retrieves a particular cookie value from a set of javax.servlet.http.Cookie objects.
static java.lang.String getDefaultDestination(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the default destination of the p13n app associated with the provided javax.servlet.http.HttpServletRequest.
static java.lang.String getDefaultSuccessor(javax.servlet.http.HttpServletRequest aRequest)
          Get the default succssor (group) that was specified in the servlet registration.
static java.util.Hashtable getDequalifiedSessionValues(javax.servlet.http.HttpServletRequest request)
          Deprecated. As of WLPS 3.1, replaced by getSessionValues(HttpServletRequest request)
static boolean getLoggedIn(javax.servlet.http.HttpServletRequest aRequest)
          Determines whether a user is currently logged into the p13n app.
static java.lang.String getRepositoryDirectory(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the repository directory of the p13n application associated with the provided javax.servlet.http.HttpServletRequest.
static javax.servlet.ServletConfig getServletConfig(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the current ServletConfig object, as set by the default destination determiner.
static java.lang.Object getSessionValue(java.lang.String aName, javax.servlet.http.HttpServletRequest aRequest)
          Retrieves a session value based on the name provided.
static java.lang.Object getSessionValue(java.lang.String scopeName, java.lang.String aName, javax.servlet.http.HttpServletRequest aRequest)
          Retrieves a session value based on the name provided.
static java.util.Map getSessionValues(javax.servlet.http.HttpServletRequest request)
          Retrieves a map of session property names and their corresponding values for the provided request.
static java.util.Map getSessionValues(javax.servlet.http.HttpServletRequest request, com.beasys.commerce.axiom.util.filter.MapFilter filter)
          Retrieves a map of session property names and their corresponding values for the provided request.
static java.lang.String getTrafficURI(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the URI of the FlowManager associated with the request.
static java.lang.String getTrafficURINoContext(javax.servlet.http.HttpServletRequest aRequest)
          Get traffic URI with no context.
static java.lang.String getWorkingDirectory(javax.servlet.http.HttpServletRequest aRequest)
          Retrieves the working directory of the p13n app associated with the provided javax.servlet.http.HttpServletRequest.
static boolean isWar(javax.servlet.ServletContext ctx)
          Determines if the context is deployed as a WAR file
static void putSessionValue(java.lang.String aName, java.lang.Object aValue, javax.servlet.http.HttpServletRequest aRequest)
          Sets a session value based on the name provided.
static void putSessionValue(java.lang.String scopeName, java.lang.String aName, java.lang.Object aValue, javax.servlet.http.HttpServletRequest aRequest)
          Sets a session value based on the scope name and propertyname provided.
static java.lang.String qualifiedName(java.lang.String aBaseName, javax.servlet.http.HttpServletRequest aRequest)
          Creates a name, based on the provided base name, which uniquely identifies a session paramater as belonging to a particular FlowManager.
static void removeSessionValue(java.lang.String aName, javax.servlet.http.HttpServletRequest aRequest)
          Removes a session value based on the name provided.
static void setCookie(java.lang.String aName, java.lang.String aValue, javax.servlet.http.Cookie[] cookies, javax.servlet.http.HttpServletResponse aResponse, int aMaxAge)
          Locates a javax.servlet.http.Cookie with a name matching the provided name, and sets the value of the Cookie to the provided value.
static void setSessionValue(java.lang.String aName, java.lang.Object aValue, javax.servlet.http.HttpServletRequest aRequest)
          Sets a session value based on the name provided.
static void setSessionValue(java.lang.String scopeName, java.lang.String aName, java.lang.Object aValue, javax.servlet.http.HttpServletRequest aRequest)
          Sets a session value based on the scope name and propertyname provided.
static boolean validSession(javax.servlet.http.HttpServletRequest aRequest)
          Checks to see if the session has all of the valid values for p13n run-time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JspHelper

public JspHelper()
Method Detail

validSession

public static boolean validSession(javax.servlet.http.HttpServletRequest aRequest)
Checks to see if the session has all of the valid values for p13n run-time. Also checks to see the session has timed out.
Parameters:
the - javax.servlet.http.HttpServletRequest from which the session is retreived
Returns:
boolean whether the session is valid

findCookie

public static javax.servlet.http.Cookie findCookie(java.lang.String aName,
                                                   javax.servlet.http.Cookie[] cookies)
Finds the cookie for a given cookie name.
Parameters:
aName - the cookie name
cookies - an array of cookies previously obtain from from the request.
Returns:
Cookie the cookie if found, null if not.

getDefaultSuccessor

public static java.lang.String getDefaultSuccessor(javax.servlet.http.HttpServletRequest aRequest)
Get the default succssor (group) that was specified in the servlet registration.
Parameters:
aRequest. -  
Returns:
the default successor.

encode

public static java.lang.String encode(java.lang.String aString)
Encodes the provided String using a Base64Encoder.
Parameters:
aString - the String to encode
Returns:
String the encoded version of the provided String

decode

public static java.lang.String decode(java.lang.String aString)
                               throws java.io.IOException
Decodes the provided String using a Base64Decoder.
Parameters:
the - String to decode
Returns:
String the decoded version of the provided String
Throws:
IOException - buffer read error

setCookie

public static void setCookie(java.lang.String aName,
                             java.lang.String aValue,
                             javax.servlet.http.Cookie[] cookies,
                             javax.servlet.http.HttpServletResponse aResponse,
                             int aMaxAge)
Locates a javax.servlet.http.Cookie with a name matching the provided name, and sets the value of the Cookie to the provided value. Also, sets the maximum age of the Cookie to the age provided. If a cookie is not found in the provided array, a new cookie is created, and appropriate values are set.
Parameters:
aName - the Cookie name
aValue - the new Cookie value
cookies - the array of Cookie object searched for the provided name
aResponse - the javax.servlet.http.HttpServletResponse to which the cookie is added
aMaxAge - the maximum cookie age, in seconds

getTrafficURI

public static java.lang.String getTrafficURI(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the URI of the FlowManager associated with the request.
Parameters:
aRequest - the request used to obtain the Traffic URI.
Returns:
String Returns the JspService Manager, null none exists for this request.

getTrafficURINoContext

public static java.lang.String getTrafficURINoContext(javax.servlet.http.HttpServletRequest aRequest)
Get traffic URI with no context. Required for jsp:forward.
Parameters:
aRequest -  
Returns:
String

getWorkingDirectory

public static java.lang.String getWorkingDirectory(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the working directory of the p13n app associated with the provided javax.servlet.http.HttpServletRequest.
Parameters:
aRequest - the HttpServletRequest associated with the p13n app
Returns:
String the working directory of the p13n app, returns null if none exists.

getRepositoryDirectory

public static java.lang.String getRepositoryDirectory(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the repository directory of the p13n application associated with the provided javax.servlet.http.HttpServletRequest.
Parameters:
aRequest - the HttpServletRequest associated with the portal
Returns:
String the working directory of the p13n app, returns null if none exists.

getDefaultDestination

public static java.lang.String getDefaultDestination(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the default destination of the p13n app associated with the provided javax.servlet.http.HttpServletRequest. This value is the destination to which the FlowManager directs the browser when no alternate destination is provided to the FlowManager.
Parameters:
aRequest - the HttpServletRequest associated with the p13n app
Returns:
String the default destination of the p13n app

getServletConfig

public static javax.servlet.ServletConfig getServletConfig(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the current ServletConfig object, as set by the default destination determiner.
Parameters:
the - javax.servlet.http.HttpServletRequest corresponding to the FlowManager
Returns:
ServletConfig the current request's configuration

isWar

public static boolean isWar(javax.servlet.ServletContext ctx)
Determines if the context is deployed as a WAR file
Parameters:
ctx - The ServletContext associated with this handler.
Returns:
true if a WAR, false if not.

qualifiedName

public static java.lang.String qualifiedName(java.lang.String aBaseName,
                                             javax.servlet.http.HttpServletRequest aRequest)
Creates a name, based on the provided base name, which uniquely identifies a session paramater as belonging to a particular FlowManager. This prevents naming collisions between multiple p13n app instances, as multiple p13n apps can be part of the same session. If a FlowManager is not present then the 'aBaseName' parameter is used without any namespacing.
Parameters:
aBaseName - the base parameter name (e.g. "userName")
aRequest - the HttpServletRequest used to retrieve the Traffic URI, and therefore the correct FlowManager name.
Returns:
String

getCookieValue

public static java.lang.String getCookieValue(java.lang.String aName,
                                              javax.servlet.http.Cookie[] cookies)
                                       throws java.io.IOException
Retrieves a particular cookie value from a set of javax.servlet.http.Cookie objects.
Parameters:
aName - the name of the Cookie from which the value is sought
cookies - an array of Cookie objects which is searched for the cookie whose name matches the provided name
Returns:
String the value of the cookie, if found ; null otherwise
Throws:
IOException - propagated from decode.

getCookieTimeout

public static int getCookieTimeout(javax.servlet.http.HttpServletRequest aRequest)
Retrieves the p13n app Cookie timeout, in seconds.
Parameters:
aRequest - the javax.servlet.http.HttpServletRequest associated with the p13n app
Returns:
int the Cookie timeout, in seconds.

getLoggedIn

public static boolean getLoggedIn(javax.servlet.http.HttpServletRequest aRequest)
Determines whether a user is currently logged into the p13n app.
Parameters:
aRequest - the javax.servle.http.HttpServletRequest used to retrieve the p13n app's session
Returns:
boolean whether a user is currently logged into the p13n app

getSessionValue

public static java.lang.Object getSessionValue(java.lang.String aName,
                                               javax.servlet.http.HttpServletRequest aRequest)
Retrieves a session value based on the name provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among p13n apps which co-exist in the same session. If no FlowManager exists for this request, then the FlowManager namespacing is ignored.
Parameters:
aName - the name of the session value to be retrieved
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

getSessionValue

public static java.lang.Object getSessionValue(java.lang.String scopeName,
                                               java.lang.String aName,
                                               javax.servlet.http.HttpServletRequest aRequest)
Retrieves a session value based on the name provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among p13n apps which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
scopeName - the scope associated with the property
aName - the name of the session value to be retrieved
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

setSessionValue

public static void setSessionValue(java.lang.String aName,
                                   java.lang.Object aValue,
                                   javax.servlet.http.HttpServletRequest aRequest)
Sets a session value based on the name provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among p13n apps which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
aName - the name of the session value to be set
aValue - the new session value
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

putSessionValue

public static void putSessionValue(java.lang.String aName,
                                   java.lang.Object aValue,
                                   javax.servlet.http.HttpServletRequest aRequest)
Sets a session value based on the name provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among p13n apps which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
aName - the name of the session value to be set
aValue - the new session value
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

putSessionValue

public static void putSessionValue(java.lang.String scopeName,
                                   java.lang.String aName,
                                   java.lang.Object aValue,
                                   javax.servlet.http.HttpServletRequest aRequest)
Sets a session value based on the scope name and propertyname provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among applications which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
scopeName - the name of the scope associated with the session value
aName - the name of the session value to be set
aValue - the new session value
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

setSessionValue

public static void setSessionValue(java.lang.String scopeName,
                                   java.lang.String aName,
                                   java.lang.Object aValue,
                                   javax.servlet.http.HttpServletRequest aRequest)
Sets a session value based on the scope name and propertyname provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among applications which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
scopeName - the name of the scope associated with the session value
aName - the name of the session value to be set
aValue - the new session value
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

removeSessionValue

public static void removeSessionValue(java.lang.String aName,
                                      javax.servlet.http.HttpServletRequest aRequest)
Removes a session value based on the name provided. This name is a base name, which is qualified to correspond to a particular FlowManager, so that naming collisions are avoided among p13n apps which co-exist in the same session. If no FlowManager exists for the request, then the FlowManager namespacing is ignored.
Parameters:
aName - the name of the session value to be removed
aRequest - the javax.servlet.http.HttpServletRequest used to retrieve the current session
Returns:
Object

getDequalifiedSessionValues

public static java.util.Hashtable getDequalifiedSessionValues(javax.servlet.http.HttpServletRequest request)
Deprecated. As of WLPS 3.1, replaced by getSessionValues(HttpServletRequest request)

Retrieves a hashtable of dequalified session property names and their corresponding values for the provided request.
Parameters:
request - the request whose session's values are sought
Returns:
a hash table of dequalified name-value pairs : null if no traffic URI is obtained

getSessionValues

public static java.util.Map getSessionValues(javax.servlet.http.HttpServletRequest request)
Retrieves a map of session property names and their corresponding values for the provided request. Takes care of application name spacing.
Parameters:
request - the request whose session's values are sought
Returns:
a map of name-value pairs : null if no traffic URI is obtained

getSessionValues

public static java.util.Map getSessionValues(javax.servlet.http.HttpServletRequest request,
                                             com.beasys.commerce.axiom.util.filter.MapFilter filter)
Retrieves a map of session property names and their corresponding values for the provided request. Takes care of application name spacing.
Parameters:
request - the request whose session's values are sought
Returns:
a map of name-value pairs : null if no traffic URI is obtained

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved