org.moremotion.servlet
Class MoreMotionServletRequest

java.lang.Object
  extended by org.moremotion.servlet.MoreMotionRequest
      extended by org.moremotion.servlet.MoreMotionServletRequest

public class MoreMotionServletRequest
extends MoreMotionRequest

MoreMotionRequest is the most important class of the MoreMotion Application Framework. It provides methods suitable with the way MoreMotion responds to request. One significant functionality provided by this class is decoding the request parameters correctly.

Request Parameter Decoding

When a request is sent to the server, the parameters existing in the request are encoded by the browsers using an encoding, i.e. ISO-8859-1. When an application server receives a request, it decodes these parameters and prepare a request object to pass to the Servlet.

If the application server does not use the same encoding that the browser used to encode the parameters during the decoding, the request parameters can get corrupted. Unfortunately this is the case for Tomcat. Tomcat always decode the request parameters using ISO-8859-1.

MoreMotion solves this problem with the help of the request parameter "_enc". In order to benefit from this functionality, a hidden input field with name "_enc" must be placed in the form elements and their values must be set to the encoding of the current page.

If you get the value of a request parameter by using the methods provided by this class, i.e. getParameter(), the value will be decoded using the encoding value supplied by this "_enc" parameter.

 String name = request.getParameter("name",null);
 // The name string will get the decoded "name" parameter.
 
However, some application servers can nicely guess the case and reads request parameters correctly. In that case you should disable the parameter conversion by setting the following system parameter to false.
 <enableParameterConversion>false</enableParameterConversion>
 

Version:
$Id: MoreMotionRequest.java 388 2009-06-26 18:01:47Z erkan $

Constructor Summary
MoreMotionServletRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 void buildErrorResponse(java.lang.String name)
           
 void buildingErrorResponse()
           
 void buildResponse(java.lang.String name)
           
 void generateDefaultErrorPage()
          Generates the default error page.
 void generatePage(java.lang.String pageName)
          Generates (Displays) the specified page.
 boolean generatingErrorPage()
          Returns true if currently an error page is being generated
 int getAllowCaching()
          Returns the allowCaching value.
 java.lang.String getApplicationPath()
          Returns the Application Path of the current web application.
 java.lang.Object getAttribute(java.lang.String str)
           
 java.util.Enumeration getAttributeNames()
           
 java.lang.String getAuthType()
           
 java.lang.String getCharacterEncoding()
           
 java.lang.String getConfigurationScope()
           
 int getContentLength()
           
 java.lang.String getContentType()
           
 java.lang.String getContextPath()
           
 javax.servlet.http.Cookie[] getCookies()
           
 java.lang.String getCookieValue(java.lang.String cookieName)
          Returns the value of the specified cookie.
 CurrentPage getCurrentPage()
          Returns the CurrentPage object associated with this request
 long getDateHeader(java.lang.String str)
           
 java.lang.String getHeader(java.lang.String str)
           
 java.util.Enumeration getHeaderNames()
           
 java.util.Enumeration getHeaders(java.lang.String str)
           
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Returns the original HttpServletRequest object.
 javax.servlet.ServletInputStream getInputStream()
           
 int getIntHeader(java.lang.String str)
           
 java.lang.String getLanguage()
          Returns the current language code
 java.lang.String getLocalAddr()
           
 java.util.Locale getLocale()
           
 java.util.Enumeration getLocales()
           
 java.lang.String getLocalName()
           
 int getLocalPort()
           
 java.lang.String getMethod()
           
 java.lang.String getOriginPage()
          The name of the origin page that is taken from request parameter "_originpage".
 java.lang.String getOriginPage(boolean withVariant)
          The name of the origin page that is taken from request parameter "_originpage".
 java.lang.String getParameter(java.lang.String parmName)
          Returns the value of the specified request parameter.
 java.lang.String getParameter(java.lang.String parmName, java.lang.String defValue)
          Returns the value of the specified request parameter.
 java.util.Map getParameterMap()
           
 java.util.Enumeration getParameterNames()
           
 java.lang.String[] getParameterValues(java.lang.String parmName)
          Returns a String array that contains the values of the specified parameter.
 java.lang.String getPathInfo()
           
 java.lang.String getPathTranslated()
           
 java.lang.String getPlainParameter(java.lang.String parmName)
          Returns the value of the specified parameter.
 java.lang.String getPlainParameter(java.lang.String parmName, java.lang.String defValue)
          Returns the value of the specified parameter.
 java.lang.String getProtocol()
           
 java.lang.String getQueryString()
           
 java.io.BufferedReader getReader()
           
 java.lang.String getRemoteAddr()
           
 java.lang.String getRemoteHost()
           
 int getRemotePort()
           
 java.lang.String getRemoteUser()
           
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String str)
           
 java.lang.String getRequestedSessionId()
           
 java.lang.String getRequestInfo(java.lang.String info)
           
 java.lang.String getRequestURI()
           
 java.lang.StringBuffer getRequestURL()
           
 javax.servlet.http.HttpServletResponse getResponse()
           
 java.lang.String getScheme()
           
 java.lang.String getServerName()
           
 int getServerPort()
           
 java.lang.String getServletPath()
           
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.http.HttpSession getSession(boolean param)
           
 java.lang.String[] getSourceAreaNames()
          Returns the names of the Ajax source area names
 java.security.Principal getUserPrincipal()
           
 boolean isAjaxRequest()
           
 boolean isRequestedSessionIdFromCookie()
           
 boolean isRequestedSessionIdFromUrl()
           
 boolean isRequestedSessionIdFromURL()
           
 boolean isRequestedSessionIdValid()
           
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String str)
           
 void removeAttribute(java.lang.String str)
           
 java.lang.String resolve(java.lang.String str)
          Resolves the MScript functions existing in the given string and returns it.
 void setAjaxRequest(boolean value)
           
 void setAllowCaching(int value)
           
 void setAttribute(java.lang.String str, java.lang.Object obj)
           
 void setCharacterEncoding(java.lang.String str)
           
 void setCookieValue(java.lang.String cookieName, java.lang.String cookieValue, int maxAge)
          Sets a cookie.
 void setCurrentPage(CurrentPage value)
          Sets the CurrentPage object to let the methods of this class to access all the necessary information about the current page.
 void setNoCache()
          Sets the necessary response header information for the requesting browser to tell it not to cache the response.
 void setSourceAreaNames(java.lang.String names)
          Sets the names of the Ajax Source Areas
 
Methods inherited from class org.moremotion.servlet.MoreMotionRequest
adjustVarsToPage, createMessage, createMessage, getApplicationADOM, getContext, getForcedDatasources, getMMResponse, getMMSession, getOutputFile, getParameterAsBoolean, getParameterAsDouble, getParameterAsInt, getRealFile, getRealFile, getRealPath, getRelativePath, getRequestADOM, getResourceText, getResourceText, getResponded, getSessionADOM, getStack, getSymbolResolver, getVars, getVPool, includeInPageXML, newApplicationADOM, newRequestADOM, newSessionADOM, peek, pop, processClosables, push, registerClosable, removeApplicationADOM, removeRequestADOM, removeSessionADOM, setResponded
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoreMotionServletRequest

public MoreMotionServletRequest(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
Method Detail

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Overrides:
getResponse in class MoreMotionRequest

setAllowCaching

public void setAllowCaching(int value)

isAjaxRequest

public boolean isAjaxRequest()

setAjaxRequest

public void setAjaxRequest(boolean value)

getAllowCaching

public int getAllowCaching()
Returns the allowCaching value. The valued values are -1: No, 0: Page Defined, 1: Yes


generatingErrorPage

public boolean generatingErrorPage()
Returns true if currently an error page is being generated


setSourceAreaNames

public void setSourceAreaNames(java.lang.String names)
Sets the names of the Ajax Source Areas

Parameters:
names - The names of the source areas Delimited with commas

getSourceAreaNames

public java.lang.String[] getSourceAreaNames()
Returns the names of the Ajax source area names


getLanguage

public java.lang.String getLanguage()
Returns the current language code

Specified by:
getLanguage in class MoreMotionRequest

getOriginPage

public java.lang.String getOriginPage(boolean withVariant)
The name of the origin page that is taken from request parameter "_originpage".

Parameters:
withVariant - True if the page variant to be added to the page name.

getConfigurationScope

public java.lang.String getConfigurationScope()
Specified by:
getConfigurationScope in class MoreMotionRequest

getOriginPage

public java.lang.String getOriginPage()
The name of the origin page that is taken from request parameter "_originpage". The name of the page variant is added to the page name if applicable.


setCookieValue

public void setCookieValue(java.lang.String cookieName,
                           java.lang.String cookieValue,
                           int maxAge)
Sets a cookie.

Specified by:
setCookieValue in class MoreMotionRequest
Parameters:
cookieName - the Name of the cookie to set.
cookieValue - the value for the cookie.
maxAge - the duration of the cookie is seconds.

getCookieValue

public java.lang.String getCookieValue(java.lang.String cookieName)
Returns the value of the specified cookie.

Specified by:
getCookieValue in class MoreMotionRequest
Parameters:
cookieName - the Name of the cookie to set.
Returns:
null if the cookie is not found, otherwise the value of it.

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Returns the original HttpServletRequest object.


generatePage

public void generatePage(java.lang.String pageName)
                  throws PageGenerationException
Generates (Displays) the specified page.

Overrides:
generatePage in class MoreMotionRequest
Parameters:
pageName - Name of the page to generate. It is usually the name of the XSL file without extension.
Throws:
PageGenerationException - if generation fails.

generateDefaultErrorPage

public void generateDefaultErrorPage()
                              throws PageGenerationException
Generates the default error page.

Overrides:
generateDefaultErrorPage in class MoreMotionRequest
Throws:
PageGenerationException

buildResponse

public void buildResponse(java.lang.String name)
                   throws ResponseBuildingException
Specified by:
buildResponse in class MoreMotionRequest
Throws:
ResponseBuildingException

buildErrorResponse

public void buildErrorResponse(java.lang.String name)
                        throws ResponseBuildingException
Specified by:
buildErrorResponse in class MoreMotionRequest
Throws:
ResponseBuildingException

buildingErrorResponse

public void buildingErrorResponse()
Specified by:
buildingErrorResponse in class MoreMotionRequest

resolve

public java.lang.String resolve(java.lang.String str)
                         throws MScriptException
Resolves the MScript functions existing in the given string and returns it.

Overrides:
resolve in class MoreMotionRequest
Parameters:
str - the input string
Returns:
resolved String
Throws:
MScriptException

getPlainParameter

public java.lang.String getPlainParameter(java.lang.String parmName)
Returns the value of the specified parameter. Note that this method cannot be used to retrieve the values of the encrypted parameters.

Specified by:
getPlainParameter in class MoreMotionRequest

getPlainParameter

public java.lang.String getPlainParameter(java.lang.String parmName,
                                          java.lang.String defValue)
Returns the value of the specified parameter. Note that this method cannot be used to retrieve the values of the encrypted parameters.

Specified by:
getPlainParameter in class MoreMotionRequest

getParameter

public java.lang.String getParameter(java.lang.String parmName)
Returns the value of the specified request parameter. It returns null if the parameters is not found.

Specified by:
getParameter in class MoreMotionRequest

getParameter

public java.lang.String getParameter(java.lang.String parmName,
                                     java.lang.String defValue)
Returns the value of the specified request parameter. If the parameter is not found returns the default value.

Specified by:
getParameter in class MoreMotionRequest

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String parmName)
Returns a String array that contains the values of the specified parameter. This method is used if the request potentially contains the same parameter more than one. i.e. MyServlet?code=1&code=4&code=11

Specified by:
getParameterValues in class MoreMotionRequest

getRequestInfo

public java.lang.String getRequestInfo(java.lang.String info)
Specified by:
getRequestInfo in class MoreMotionRequest

getApplicationPath

public java.lang.String getApplicationPath()
Returns the Application Path of the current web application.

Specified by:
getApplicationPath in class MoreMotionRequest

setCurrentPage

public void setCurrentPage(CurrentPage value)
                    throws PageGenerationException
Sets the CurrentPage object to let the methods of this class to access all the necessary information about the current page.

Throws:
PageGenerationException

getCurrentPage

public CurrentPage getCurrentPage()
Returns the CurrentPage object associated with this request


setNoCache

public void setNoCache()
Sets the necessary response header information for the requesting browser to tell it not to cache the response.

Specified by:
setNoCache in class MoreMotionRequest

getContentType

public java.lang.String getContentType()

isSecure

public boolean isSecure()

getServerName

public java.lang.String getServerName()

getServerPort

public int getServerPort()

getLocale

public java.util.Locale getLocale()

getAttribute

public java.lang.Object getAttribute(java.lang.String str)
Specified by:
getAttribute in class MoreMotionRequest

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Throws:
java.io.IOException

getScheme

public java.lang.String getScheme()

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()

getSession

public javax.servlet.http.HttpSession getSession()
Overrides:
getSession in class MoreMotionRequest

getSession

public javax.servlet.http.HttpSession getSession(boolean param)

getParameterNames

public java.util.Enumeration getParameterNames()
Specified by:
getParameterNames in class MoreMotionRequest

getLocales

public java.util.Enumeration getLocales()

getRemoteHost

public java.lang.String getRemoteHost()

getContentLength

public int getContentLength()

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Throws:
java.io.IOException

getPathTranslated

public java.lang.String getPathTranslated()

getServletPath

public java.lang.String getServletPath()

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String str)

removeAttribute

public void removeAttribute(java.lang.String str)
Specified by:
removeAttribute in class MoreMotionRequest

getIntHeader

public int getIntHeader(java.lang.String str)

getHeaderNames

public java.util.Enumeration getHeaderNames()

getCharacterEncoding

public java.lang.String getCharacterEncoding()

getPathInfo

public java.lang.String getPathInfo()

getCookies

public javax.servlet.http.Cookie[] getCookies()

getRemoteAddr

public java.lang.String getRemoteAddr()

getQueryString

public java.lang.String getQueryString()

getAuthType

public java.lang.String getAuthType()

isUserInRole

public boolean isUserInRole(java.lang.String str)

getMethod

public java.lang.String getMethod()
Specified by:
getMethod in class MoreMotionRequest

getHeader

public java.lang.String getHeader(java.lang.String str)

getRequestURI

public java.lang.String getRequestURI()

setAttribute

public void setAttribute(java.lang.String str,
                         java.lang.Object obj)
Specified by:
setAttribute in class MoreMotionRequest

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()

getUserPrincipal

public java.security.Principal getUserPrincipal()

getAttributeNames

public java.util.Enumeration getAttributeNames()

getRequestedSessionId

public java.lang.String getRequestedSessionId()

getDateHeader

public long getDateHeader(java.lang.String str)

getProtocol

public java.lang.String getProtocol()

getRemoteUser

public java.lang.String getRemoteUser()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()

getContextPath

public java.lang.String getContextPath()
Specified by:
getContextPath in class MoreMotionRequest

getHeaders

public java.util.Enumeration getHeaders(java.lang.String str)

setCharacterEncoding

public void setCharacterEncoding(java.lang.String str)
                          throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

getParameterMap

public java.util.Map getParameterMap()

getRequestURL

public java.lang.StringBuffer getRequestURL()

getLocalAddr

public java.lang.String getLocalAddr()

getLocalName

public java.lang.String getLocalName()

getLocalPort

public int getLocalPort()

getRemotePort

public int getRemotePort()


Copyright © 2002-2011 MOR YAZILIM. All Rights Reserved.