nu.staldal.lsp.servlet
Class LSPServletContext

java.lang.Object
  extended by nu.staldal.lsp.servlet.LSPServletContext

public class LSPServletContext
extends java.lang.Object

Context for LSP extension libraries executed in Servlet environment.


Constructor Summary
LSPServletContext(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, LSPManager lspManager)
          Create an LSPServletContext.
 
Method Summary
 java.lang.String encodeURL(java.lang.String url)
          Encode an URL for Servlet session tracking.
 LSPManager getLSPManager()
          Get the LSPManager.
 javax.servlet.ServletContext getServletContext()
          Get the ServletContext.
 javax.servlet.http.HttpServletRequest getServletRequest()
          Get the HttpServletRequest.
 javax.servlet.http.HttpServletResponse getServletResponse()
          Get the HttpServletResponse.
 boolean isUserInRole(java.lang.String role)
          Check if user is in role.
 java.lang.String lang(java.lang.String key)
          Get a localized resource for the user's locale.
 java.lang.String lang(java.lang.String pageName, java.lang.String key)
          Get a localized resource for the user's locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LSPServletContext

public LSPServletContext(javax.servlet.ServletContext servletContext,
                         javax.servlet.http.HttpServletRequest servletRequest,
                         javax.servlet.http.HttpServletResponse servletResponse,
                         LSPManager lspManager)
Create an LSPServletContext.

Parameters:
servletContext - ServletContext
servletRequest - HttpServletRequest
servletResponse - HttpServletResponse
lspManager - LSPManager
Method Detail

getServletContext

public javax.servlet.ServletContext getServletContext()
Get the ServletContext.

Returns:
the ServletContext

getServletRequest

public javax.servlet.http.HttpServletRequest getServletRequest()
Get the HttpServletRequest.

Returns:
the HttpServletRequest

getServletResponse

public javax.servlet.http.HttpServletResponse getServletResponse()
Get the HttpServletResponse.

Returns:
the HttpServletResponse

getLSPManager

public LSPManager getLSPManager()
Get the LSPManager.

Returns:
the LSPManager

lang

public java.lang.String lang(java.lang.String pageName,
                             java.lang.String key)
                      throws java.lang.Exception
Get a localized resource for the user's locale.

This method is used by the LSP ExtLib lang element and function.

Parameters:
pageName - LSP page name, or null for global resources only
key - the key
Returns:
[key] if not found.
Throws:
java.lang.Exception - if the LocaleBundleFactory throws any exception

lang

public java.lang.String lang(java.lang.String key)
                      throws java.lang.Exception
Get a localized resource for the user's locale.

Same as lang(null,key).

Parameters:
key - the key
Returns:
[key] if not found.
Throws:
java.lang.Exception - if the LocaleBundleFactory throws any exception

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Encode an URL for Servlet session tracking.

Parameters:
url - the URL to encode
Returns:
the encoded URL
See Also:
HttpServletResponse.encodeURL(java.lang.String)

isUserInRole

public boolean isUserInRole(java.lang.String role)
Check if user is in role.

Parameters:
role - the role to check
Returns:
true if user is in the given role
See Also:
HttpServletRequest.isUserInRole(String)