|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.moremotion.servlet.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>
| Field Summary |
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
MoreMotionRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
|
| Method Summary | |
void |
adjustVarsToPage(java.lang.String pageName)
|
ADOMNode |
createMessage(java.lang.Exception exception)
Creates a new Request Datasource for the message if not already created and adds the given message in it. |
ADOMNode |
createMessage(java.lang.String unitName,
java.lang.String messageId,
java.lang.String[] arguments,
java.lang.Object details)
Creates a new Request Datasource for the message if not already created and adds the given message in it. |
void |
generateDefaultErrorPage()
Generates the default error page. |
void |
generatePage(java.lang.String pageName)
Generates (Displays) the specified page. |
boolean |
generatingErrorPage()
|
int |
getAllowCaching()
|
ADOM |
getApplicationADOM(java.lang.String name)
Returns the ADOM saved to servlet context by the given name. |
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()
|
int |
getContentLength()
|
java.lang.String |
getContentType()
|
javax.servlet.ServletContext |
getContext()
Returns the ServletContext object |
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()
|
long |
getDateHeader(java.lang.String str)
|
java.util.Hashtable |
getForcedDatasources()
Returns the list of the datasource thats were forced to be included in the page XML data. |
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 |
getPageLocation()
|
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. |
boolean |
getParameterAsBoolean(java.lang.String prmname,
boolean defVal)
Returns the value of the request parameters as boolean. |
double |
getParameterAsDouble(java.lang.String parmName,
double defValue)
Returns the value of the request parameters as double. |
int |
getParameterAsInt(java.lang.String parmName,
int defValue)
Returns the value of the request parameters as int. |
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.io.File |
getRealFile(java.lang.String fileName)
Returns the file object of the real file for the specified file name relative to web application path. |
java.lang.String |
getRealPath(java.lang.String str)
|
java.lang.String |
getRemoteAddr()
|
java.lang.String |
getRemoteHost()
|
int |
getRemotePort()
|
java.lang.String |
getRemoteUser()
|
ADOM |
getRequestADOM(java.lang.String name)
Returns the ADOM saved to request by the given name. |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String str)
|
java.lang.String |
getRequestedSessionId()
|
java.lang.String |
getRequestURI()
|
java.lang.StringBuffer |
getRequestURL()
|
boolean |
getResponded()
Returns true if the a response is already prepared for this request. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the HttpServletResponse object. |
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)
|
ADOM |
getSessionADOM(java.lang.String name)
Returns the ADOM saved to session by the given name. |
java.lang.String[] |
getSourceAreaNames()
|
MMSymbolResolver |
getSymbolResolver()
Returns the Symbol MScriptResolver object that this request is associated. |
int |
getUnitDebugLevel(java.lang.String unit)
Returns the debugging level of an unit. |
java.security.Principal |
getUserPrincipal()
|
Vars |
getVars()
|
VariablePool |
getVPool()
Returns the variable pool object that is associated with this request |
void |
includeInPageXML(java.lang.String dsname,
java.lang.String resBundleName,
ADOM adom)
This method forces MoreMotion to include the content of the specified datasource to the page XML data even though there is no explicit reference to it in the page to be displayed next. |
boolean |
isRequestedSessionIdFromCookie()
|
boolean |
isRequestedSessionIdFromUrl()
|
boolean |
isRequestedSessionIdFromURL()
|
boolean |
isRequestedSessionIdValid()
|
boolean |
isSecure()
|
boolean |
isUserInRole(java.lang.String str)
|
ADOM |
newApplicationADOM(java.lang.String name)
Creates a new Application ADOM and saves it in the servlet context. |
ADOM |
newRequestADOM(java.lang.String name)
Creates a new protected Request ADOM and saves it in the request. |
ADOM |
newSessionADOM(java.lang.String name)
Creates a new protected Session ADOM and saves it in the session. |
void |
removeApplicationADOM(java.lang.String name)
Removes ADOM from servlet context by given name. |
void |
removeAttribute(java.lang.String str)
|
void |
removeRequestADOM(java.lang.String name)
Removes ADOM from request by given name. |
void |
removeSessionADOM(java.lang.String name)
Removes ADOM from session by given name. |
java.lang.String |
resolve(java.lang.String str)
Resolves the MScript functions existing in the given string and returns it. |
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 |
setGeneratingErrorPage()
|
void |
setPageLocation(java.lang.String loc)
|
void |
setResponded(boolean value)
This method can be used to notify to the MoreMotion that a response is already given by you so he should not bother generating a page. |
void |
setSourceAreaNames(java.lang.String names)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MoreMotionRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
| Method Detail |
public void setResponded(boolean value)
public boolean getResponded()
true if the a response is already prepared for this request.
public void setAllowCaching(int value)
public int getAllowCaching()
public boolean generatingErrorPage()
public void setGeneratingErrorPage()
public void setSourceAreaNames(java.lang.String names)
public java.lang.String[] getSourceAreaNames()
public MMSymbolResolver getSymbolResolver()
public void adjustVarsToPage(java.lang.String pageName)
public Vars getVars()
public int getUnitDebugLevel(java.lang.String unit)
unit - The name of the unit.
public VariablePool getVPool()
public java.lang.String getLanguage()
public java.lang.String getOriginPage()
public void setCookieValue(java.lang.String cookieName,
java.lang.String cookieValue,
int maxAge)
cookieName - the Name of the cookie to set.cookieValue - the value for the cookie.maxAge - the duration of the cookie is seconds.public java.lang.String getCookieValue(java.lang.String cookieName)
cookieName - the Name of the cookie to set.
null if the cookie is not found, otherwise the value of it.
public ADOMNode createMessage(java.lang.String unitName,
java.lang.String messageId,
java.lang.String[] arguments,
java.lang.Object details)
unitName - Name of the reporting unit. This name will be used to name the data source to be created and the resource associated with it.messageId - Either a message text or a resource Id. The message will be taken from the resource file unitName.res with this Id. If no resource
is found with the given id in the resource file then messageId is used as the message text.arguments - the message arguments which will be used to replace argument symbols (%0, %1, etc.) existing in the message text.details - Either an Exception object that keeps the original exception or a String object that keeps the message details.
ADOMNode object to let you add extra information to the message created.
The XML Structure of the created message datasource is as follows:
<unitName_messages>
<message id="messageId">
<text>Message text taken from the resource file with the given messageId</text>
<unitname>Given unit name</unitname>
<details>Message Details. Either the Stack Trace of the orginal exception or the given details as String</details>
</message>
</unitName_messages>
Example:
ADOMNode msg = request.CreateMessage("myunit","MISSING_TABLE",new String[]{databaseName, tableName},e);
msg.setNodeValue("extrainfo","extra info .....");
request.generateDefaultErrorPage(); // To display messages using MoreMotion's default error page
request.generatePage("MyErrorPage"); // To display messages using your error page.
// You can prepare your Error Page using template element "\cpn\mor\ErrorPageTemplate.mmel"
public ADOMNode createMessage(java.lang.Exception exception)
MoreMotionException this
method can extract the message id, arguments end details from it.
If the given exception is or contains a java.sql.SQLException the returned ADOMNode object
contains two additional entries that are "jdbc-error-code" and "jdbc-sql-state".
public void includeInPageXML(java.lang.String dsname,
java.lang.String resBundleName,
ADOM adom)
dsname - The name of the datasource to include to the page XML.resBundleName - The name of the resource bundle that will be used to resolve
$res() functions existing in the datasource content.adom - the ADOM object that will provide the content.public java.util.Hashtable getForcedDatasources()
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
public void generatePage(java.lang.String pageName)
throws PageGenerationException
pageName - Name of the page to generate. It is usually the name of the XSL file without extension.
PageGenerationException - if generation fails.
public void generateDefaultErrorPage()
throws PageGenerationException
PageGenerationException
public java.lang.String resolve(java.lang.String str)
throws MScriptException
str - the input string
MScriptExceptionpublic java.lang.String getPlainParameter(java.lang.String parmName)
public java.lang.String getPageLocation()
public void setPageLocation(java.lang.String loc)
public java.lang.String getPlainParameter(java.lang.String parmName,
java.lang.String defValue)
public java.lang.String getParameter(java.lang.String parmName)
null if the parameters is not found.
getParameter in interface javax.servlet.ServletRequest
public java.lang.String getParameter(java.lang.String parmName,
java.lang.String defValue)
public int getParameterAsInt(java.lang.String parmName,
int defValue)
int.
If the parameter is not found returns the default value.
public double getParameterAsDouble(java.lang.String parmName,
double defValue)
double.
If the parameter is not found returns the default value.
public boolean getParameterAsBoolean(java.lang.String prmname,
boolean defVal)
boolean.
If the parameter is not found returns the default value.
public java.lang.String[] getParameterValues(java.lang.String parmName)
MyServlet?code=1&code=4&code=11
getParameterValues in interface javax.servlet.ServletRequestpublic javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.ServletContext getContext()
public java.lang.String getApplicationPath()
public java.io.File getRealFile(java.lang.String fileName)
fileName - Relative file name
File object of the real file.public ADOM newRequestADOM(java.lang.String name)
name - Name of the ADOM.
public ADOM newSessionADOM(java.lang.String name)
name - Name of the ADOM.
public ADOM newApplicationADOM(java.lang.String name)
name - Name of the ADOM.
public ADOM getRequestADOM(java.lang.String name)
name - Name of the ADOM.
null if ADOM cannot be found.public ADOM getSessionADOM(java.lang.String name)
name - Name of the ADOM.
null if ADOM cannot be found.public ADOM getApplicationADOM(java.lang.String name)
name - Name of the ADOM.
null if ADOM cannot be found.public void removeRequestADOM(java.lang.String name)
public void removeSessionADOM(java.lang.String name)
public void removeApplicationADOM(java.lang.String name)
public void setCurrentPage(CurrentPage value)
throws PageGenerationException
PageGenerationExceptionpublic CurrentPage getCurrentPage()
public java.lang.String getContentType()
getContentType in interface javax.servlet.ServletRequestpublic boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic java.lang.String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic int getServerPort()
getServerPort in interface javax.servlet.ServletRequestpublic java.util.Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic java.lang.Object getAttribute(java.lang.String str)
getAttribute in interface javax.servlet.ServletRequest
public java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface javax.servlet.ServletRequestjava.io.IOExceptionpublic java.lang.String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession(boolean param)
getSession in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic java.util.Enumeration getLocales()
getLocales in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequestpublic int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic java.lang.String getRealPath(java.lang.String str)
getRealPath in interface javax.servlet.ServletRequest
public javax.servlet.ServletInputStream getInputStream()
throws java.io.IOException
getInputStream in interface javax.servlet.ServletRequestjava.io.IOExceptionpublic java.lang.String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String str)
getRequestDispatcher in interface javax.servlet.ServletRequestpublic void removeAttribute(java.lang.String str)
removeAttribute in interface javax.servlet.ServletRequestpublic int getIntHeader(java.lang.String str)
getIntHeader in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic java.lang.String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.Cookie[] getCookies()
getCookies in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic java.lang.String getQueryString()
getQueryString in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic boolean isUserInRole(java.lang.String str)
isUserInRole in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getHeader(java.lang.String str)
getHeader in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequest
public void setAttribute(java.lang.String str,
java.lang.Object obj)
setAttribute in interface javax.servlet.ServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic java.security.Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic java.lang.String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic long getDateHeader(java.lang.String str)
getDateHeader in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaders(java.lang.String str)
getHeaders in interface javax.servlet.http.HttpServletRequest
public void setCharacterEncoding(java.lang.String str)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface javax.servlet.ServletRequestjava.io.UnsupportedEncodingExceptionpublic java.util.Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic java.lang.StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getLocalAddr()
getLocalAddr in interface javax.servlet.ServletRequestpublic java.lang.String getLocalName()
getLocalName in interface javax.servlet.ServletRequestpublic int getLocalPort()
getLocalPort in interface javax.servlet.ServletRequestpublic int getRemotePort()
getRemotePort in interface javax.servlet.ServletRequest
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||