com.sap.ip.me.api.runtime.jsp
Class AbstractMEHttpServlet

java.lang.Object
  extended byHttpServlet
      extended bycom.sap.ip.me.api.runtime.jsp.AbstractMEHttpServlet
All Implemented Interfaces:
Application

public abstract class AbstractMEHttpServlet
extends HttpServlet
implements Application

Base class for all mobile engine web application servlets. It supports localization (binds current Locale and resource bundles to current session), extracts events from request.

Ger.: Abstrakte Mobile Engine HttpServlet Klasse

Author:
SAP
See Also:
Serialized Form

Constructor Summary
AbstractMEHttpServlet()
           
 
Method Summary
 void activateApplication()
          Description of the Method
 void deactivateApplication()
          Description of the Method
 void destroy()
          Calls the hook method doDestroy() and then cleans up session context.
 void destroyApplication()
          Description of the Method
 void doDestroy()
          Hook method for servlet destruction.
 void doGet(HttpServletRequest request, HttpServletResponse response)
          Template method called by servlet framework to handle a http get request.
abstract  java.lang.String doHandleEvent(java.lang.String eventName, HttpServletRequest request, HttpServletResponse response)
          Abstract hook method called by doGet and doPost.
 void doInitialize()
          Hook method for servlet initialization.
 void doPost(HttpServletRequest request, HttpServletResponse response)
          Template method called by servlet framework to handle a http post request.
static java.lang.String encodeForHtml(char c)
          Encode characters to be shown in a web browser.
static java.lang.String encodeForHtml(java.lang.String ascii)
          Encode a whole string into characters to be shown in a web browser.
abstract  java.lang.String getApplicationName()
          Gets the applicationName attribute of the AbstractMEHttpServlet object
protected  java.util.Locale getLocale()
          Creates a Locale object for the user language that was set in sync properties.
static java.lang.String getMIHome()
          Returns url of the local Mobile Infrastructure home page.
protected  MEResourceBundle getResourceBundle()
          Returns the resources bundle.
protected  java.lang.String getUser()
          Deprecated. Use UserManager.getInstance().getCurrentUser() instead.
 void init()
          Template method called by servlet framwork to initialize local servlet data.
 void initApplication()
          Description of the Method
 void service(HttpServletRequest request, HttpServletResponse response)
          Activates the Application and calls super.service(...)
protected  void setResourceBundle(java.lang.String resourceBundleName)
          Saves a resource bundle name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMEHttpServlet

public AbstractMEHttpServlet()
Method Detail

service

public final void service(HttpServletRequest request,
                          HttpServletResponse response)
                   throws java.io.IOException,
                          ServletException
Activates the Application and calls super.service(...). Also note that only requests from localhost (127.0.0.1) will be processed. If a machine other than localhost tries to get access by sending a request an HTTP 403 status code will be returned.

Parameters:
request - Description of the Parameter
response - Description of the Parameter
Throws:
java.io.IOException
ServletException

getMIHome

public static java.lang.String getMIHome()
Returns url of the local Mobile Infrastructure home page.
The default value is "http://localhost:4444/".

Returns:
The url of the Mobile Infrastructure client home page

encodeForHtml

public static java.lang.String encodeForHtml(char c)
Encode characters to be shown in a web browser.

Parameters:
c - the character to be encoded
Returns:
The encoded parameter as string

encodeForHtml

public static java.lang.String encodeForHtml(java.lang.String ascii)
Encode a whole string into characters to be shown in a web browser.

Parameters:
ascii - the character to be encoded
Returns:
The encoded parameter as string

init

public void init()
          throws ServletException
Template method called by servlet framwork to initialize local servlet data. After binding current Locale to session context, the hook method doInitialize will be called.

Throws:
ServletException

destroy

public void destroy()
Calls the hook method doDestroy() and then cleans up session context.


doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws ServletException,
                  java.io.IOException
Template method called by servlet framework to handle a http get request. Extracts event name from the request and calls the hook method doHandleRequest.

Parameters:
request - Description of the Parameter
response - Description of the Parameter
Throws:
ServletException - Description of the Exception
java.io.IOException - Description of the Exception

doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
            throws ServletException,
                   java.io.IOException
Template method called by servlet framework to handle a http post request. Extracts event name from the request and calls the hook method doHandleRequest.

Parameters:
request - Description of the Parameter
response - Description of the Parameter
Throws:
ServletException - Description of the Exception
java.io.IOException - Description of the Exception

doInitialize

public void doInitialize()
                  throws ServletException
Hook method for servlet initialization. The default implementation does nothing.

Throws:
ServletException

doDestroy

public void doDestroy()
Hook method for servlet destruction. The default implementation does nothing.


doHandleEvent

public abstract java.lang.String doHandleEvent(java.lang.String eventName,
                                               HttpServletRequest request,
                                               HttpServletResponse response)
                                        throws ServletException,
                                               java.io.IOException
Abstract hook method called by doGet and doPost. This method should return the JSP to forward to or null if the HttpServletResponse contains the response for the request.

Parameters:
eventName - Description of the Parameter
request - Description of the Parameter
response - Description of the Parameter
Returns:
Description of the Return Value
Throws:
ServletException - Description of the Exception
java.io.IOException - Description of the Exception

initApplication

public void initApplication()
Description of the Method

Specified by:
initApplication in interface Application

activateApplication

public void activateApplication()
Description of the Method

Specified by:
activateApplication in interface Application

deactivateApplication

public void deactivateApplication()
Description of the Method

Specified by:
deactivateApplication in interface Application

destroyApplication

public void destroyApplication()
Description of the Method

Specified by:
destroyApplication in interface Application

getApplicationName

public abstract java.lang.String getApplicationName()
Gets the applicationName attribute of the AbstractMEHttpServlet object

Specified by:
getApplicationName in interface Application
Returns:
The applicationName value

getUser

protected java.lang.String getUser()
Deprecated. Use UserManager.getInstance().getCurrentUser() instead.

Returns the current user out of the Configuration. Returns empty String if no user is set or if any exception occured while getting user from SyncSettings.

Returns:
The user value

setResourceBundle

protected void setResourceBundle(java.lang.String resourceBundleName)
Saves a resource bundle name. With next doGet or doPost the resource bundle corresponding to that name will be put into session context.

Parameters:
resourceBundleName - The full qualified resource bundle name.

getResourceBundle

protected MEResourceBundle getResourceBundle()
Returns the resources bundle.

Returns:
The resourceBundle value

getLocale

protected java.util.Locale getLocale()
Creates a Locale object for the user language that was set in sync properties. If creation fails the default Locale will be returned.

Returns:
The locale value


Copyright © 2005 SAP AG. All Rights Reserved.