|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.moremotion.servlet.MoreMotionRequest
public abstract class 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>
| Constructor Summary | |
|---|---|
MoreMotionRequest()
|
|
| Method Summary | |
|---|---|
void |
adjustVarsToPage(java.lang.String pageName)
Lets the Vars object adjust itself to the specified page |
abstract void |
buildErrorResponse(java.lang.String name)
|
abstract void |
buildingErrorResponse()
|
abstract void |
buildResponse(java.lang.String name)
|
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()
Deprecated. |
void |
generatePage(java.lang.String pageName)
Deprecated. |
ADOM |
getApplicationADOM(java.lang.String name)
Returns the ADOM saved to servlet context by the given name. |
abstract java.lang.String |
getApplicationPath()
|
abstract java.lang.Object |
getAttribute(java.lang.String name)
|
abstract java.lang.String |
getConfigurationScope()
|
javax.servlet.ServletContext |
getContext()
|
abstract java.lang.String |
getContextPath()
|
abstract java.lang.String |
getCookieValue(java.lang.String cookieName)
|
java.util.Hashtable |
getForcedDatasources()
Returns the list of the datasource thats were forced to be included in the page XML data. |
abstract java.lang.String |
getLanguage()
Returns the current language code |
abstract java.lang.String |
getMethod()
|
MoreMotionResponse |
getMMResponse()
Returns the session object. |
MoreMotionSession |
getMMSession()
Returns the session object. |
java.io.File |
getOutputFile(java.lang.String fileName,
java.lang.String type)
Returns the file object of the real file for the specified file name relative to web application path. |
abstract java.lang.String |
getParameter(java.lang.String parmName)
Returns the value of the specified request parameter. |
abstract 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. |
abstract java.util.Enumeration |
getParameterNames()
|
abstract java.lang.String[] |
getParameterValues(java.lang.String parmName)
Returns a String array that contains the values of the specified parameter. |
abstract java.lang.String |
getPlainParameter(java.lang.String parmName)
Returns the value of the specified parameter. |
abstract java.lang.String |
getPlainParameter(java.lang.String parmName,
java.lang.String defValue)
Returns the value of the specified parameter. |
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.io.File |
getRealFile(java.lang.String fileName,
java.lang.String path)
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 |
getRelativePath(java.io.File file)
Returns the relative path (relative to the web application root)of the specified file. |
ADOM |
getRequestADOM(java.lang.String name)
Returns the ADOM saved to request by the given name. |
abstract java.lang.String |
getRequestInfo(java.lang.String info)
|
java.lang.String |
getResourceText(java.lang.String resid,
java.lang.String[] args)
|
java.lang.String |
getResourceText(java.lang.String resid,
java.lang.String[] args,
java.lang.String bundle)
|
boolean |
getResponded()
Returns true if the a response is already prepared for this request. |
javax.servlet.http.HttpServletResponse |
getResponse()
Deprecated. |
javax.servlet.http.HttpSession |
getSession()
Deprecated. |
ADOM |
getSessionADOM(java.lang.String name)
Returns the ADOM saved to session by the given name. |
java.util.Stack |
getStack(java.lang.String stackName)
|
MMSymbolResolver |
getSymbolResolver()
Returns the MoreMotion Symbol Resolver that this request is associated. |
Vars |
getVars()
Returns the Vars object associated with this request |
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. |
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. |
java.lang.Object |
peek(java.lang.String stackName)
|
void |
pop(java.lang.String stackName)
|
void |
processClosables()
|
void |
push(java.lang.String stackName,
java.lang.Object o)
|
void |
registerClosable(Closable object)
|
void |
removeApplicationADOM(java.lang.String name)
Removes ADOM from servlet context by given name. |
abstract void |
removeAttribute(java.lang.String name)
|
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. |
abstract void |
setAttribute(java.lang.String name,
java.lang.Object value)
|
abstract void |
setCookieValue(java.lang.String cookieName,
java.lang.String cookieValue,
int maxAge)
|
abstract void |
setNoCache()
|
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 one. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MoreMotionRequest()
| Method Detail |
|---|
public void setResponded(boolean value)
public boolean getResponded()
true if the a response is already prepared for this request.
public abstract java.lang.String getConfigurationScope()
public abstract java.lang.String getMethod()
public MMSymbolResolver getSymbolResolver()
public void adjustVarsToPage(java.lang.String pageName)
pageName - The name of the page to adjust the page variablespublic Vars getVars()
public VariablePool getVPool()
public abstract java.lang.String getLanguage()
public java.lang.String getResourceText(java.lang.String resid,
java.lang.String[] args)
throws ResourceException
ResourceException
public java.lang.String getResourceText(java.lang.String resid,
java.lang.String[] args,
java.lang.String bundle)
throws ResourceException
ResourceException
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 java.lang.String resolve(java.lang.String str)
throws MScriptException
str - the input string
MScriptExceptionpublic abstract java.lang.String getPlainParameter(java.lang.String parmName)
public abstract java.lang.String getPlainParameter(java.lang.String parmName,
java.lang.String defValue)
public abstract java.lang.String getParameter(java.lang.String parmName)
null if the parameters is not found.
public abstract 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 abstract java.util.Enumeration getParameterNames()
public abstract void setNoCache()
public abstract java.lang.String[] getParameterValues(java.lang.String parmName)
MyServlet?code=1&code=4&code=11
public abstract java.lang.String getRequestInfo(java.lang.String info)
public MoreMotionResponse getMMResponse()
public abstract void buildResponse(java.lang.String name)
throws ResponseBuildingException
ResponseBuildingException
public abstract void buildErrorResponse(java.lang.String name)
throws ResponseBuildingException
ResponseBuildingExceptionpublic abstract void buildingErrorResponse()
public void generatePage(java.lang.String pageName)
throws PageGenerationException
PageGenerationException
public void generateDefaultErrorPage()
throws PageGenerationException
PageGenerationExceptionpublic MoreMotionSession getMMSession()
public javax.servlet.http.HttpSession getSession()
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.ServletContext getContext()
public abstract java.lang.String getContextPath()
public java.lang.String getRealPath(java.lang.String str)
public java.lang.String getRelativePath(java.io.File file)
file - File object
public abstract java.lang.String getApplicationPath()
public abstract void setAttribute(java.lang.String name,
java.lang.Object value)
public abstract java.lang.Object getAttribute(java.lang.String name)
public abstract void removeAttribute(java.lang.String name)
public abstract void setCookieValue(java.lang.String cookieName,
java.lang.String cookieValue,
int maxAge)
public abstract java.lang.String getCookieValue(java.lang.String cookieName)
public java.io.File getRealFile(java.lang.String fileName)
Note that this function may also return a handle to a temporary file under "WEB-INF/MM-INF/~tempfiles" folder whose name is stored in a variable incase of fileName is specified in a special way.
For example request.getRealFile("v:TEMPF") means return the handle of the temporary file whose name is stored in
pool variable "TEMPF".
fileName - Relative file name
File object of the real file.
public java.io.File getRealFile(java.lang.String fileName,
java.lang.String path)
Note that this function may also return a handle to a temporary file under "WEB-INF/MM-INF/~tempfiles" folder whose name is stored in a variable incase of fileName is specified in a special way.
For example request.getRealFile("v:TEMPF") means return the handle of the temporary file whose name is stored in
pool variable "TEMPF".
fileName - Relative file namepath - The relative path of the file
File object of the real file.
public java.io.File getOutputFile(java.lang.String fileName,
java.lang.String type)
Note that this function may also return a handle to a temporary file that will be created under "WEB-INF/MM-INF/~tempfiles" folder
incase of fileName is specified in a special way. For example request.getOutputFile("v:TEMPF","text/plain") means create a file
that will be automatically deleted in 1 hour under "WEB-INF/MM-INF/~tempfiles" folder and save its name in pool variable "TEMPF".
fileName - The relative name of the output filetype - The content types of the output 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 registerClosable(Closable object)
public void processClosables()
throws java.lang.Exception
java.lang.Exception
public void push(java.lang.String stackName,
java.lang.Object o)
public java.lang.Object peek(java.lang.String stackName)
public void pop(java.lang.String stackName)
public java.util.Stack getStack(java.lang.String stackName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||