com.sibvisions.rad.server.http
Class ResourceServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.sibvisions.rad.server.http.ResourceServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
DownloadServlet, UploadServlet

public abstract class ResourceServlet
extends HttpServlet

The ResourceServlet is a simple HttpServlet for accessing resource templates.

See Also:
Serialized Form

Field Summary
static String PARAM_APPLICATION
          the URL parameter for the application name.
static String PARAM_CANCELBUTTON
          the URL parameter for the upload button text.
static String PARAM_CONURL
          the connection URL from the client.
static String PARAM_INFOTEXT
          the URL parameter for the info text.
static String PARAM_KEY
          the URL parameter for accessing the ObjectCache.
static String PARAM_RESOURCE
          the URL parameter for accessing resource files.
static String PARAM_TITLE
          the URL parameter for the title.
 
Constructor Summary
ResourceServlet()
           
 
Method Summary
protected  org.apache.commons.fileupload.FileItemStream getFileItemStream(HttpServletRequest pRequest)
          Gets the first FileItemStream inside a multipart upload.
protected  String getFileName(String pContentDisposition)
          Returns the given content-disposition headers file name.
protected  String getRequestURI(HttpServletRequest pRequest)
          Gets the request URI that was used from the client to communicate to the server.
protected abstract  String getResourceDirectoryName()
          Gets the name of the resource directory.
protected  void sendFile(String pApplication, String pFile, Hashtable<String,String> pParams, HttpServletResponse pResponse)
          Sends the content of a file to the client.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_KEY

public static final String PARAM_KEY
the URL parameter for accessing the ObjectCache.

See Also:
Constant Field Values

PARAM_RESOURCE

public static final String PARAM_RESOURCE
the URL parameter for accessing resource files.

See Also:
Constant Field Values

PARAM_CANCELBUTTON

public static final String PARAM_CANCELBUTTON
the URL parameter for the upload button text.

See Also:
Constant Field Values

PARAM_APPLICATION

public static final String PARAM_APPLICATION
the URL parameter for the application name.

See Also:
Constant Field Values

PARAM_TITLE

public static final String PARAM_TITLE
the URL parameter for the title.

See Also:
Constant Field Values

PARAM_INFOTEXT

public static final String PARAM_INFOTEXT
the URL parameter for the info text.

See Also:
Constant Field Values

PARAM_CONURL

public static final String PARAM_CONURL
the connection URL from the client.

See Also:
Constant Field Values
Constructor Detail

ResourceServlet

public ResourceServlet()
Method Detail

getResourceDirectoryName

protected abstract String getResourceDirectoryName()
Gets the name of the resource directory.

Returns:
the resource directory name

getFileName

protected String getFileName(String pContentDisposition)
Returns the given content-disposition headers file name.

Parameters:
pContentDisposition - The content-disposition headers value.
Returns:
The file name

getFileItemStream

protected org.apache.commons.fileupload.FileItemStream getFileItemStream(HttpServletRequest pRequest)
                                                                  throws IOException
Gets the first FileItemStream inside a multipart upload.

Parameters:
pRequest - the HttpServletRequest
Returns:
the FileItemStream
Throws:
IOException - if an IOException occurs.

sendFile

protected void sendFile(String pApplication,
                        String pFile,
                        Hashtable<String,String> pParams,
                        HttpServletResponse pResponse)
                 throws Exception
Sends the content of a file to the client. If the file is a html file, then all found parameter-keys, e.g. [EID], from the file, will be replaced with the mapped parameters. If a parameter was not found the no replacement will be performed.

Parameters:
pApplication - the application name
pFile - the name of the file to send
pParams - the key/value mapping for parameter replacement
pResponse - the http response
Throws:
Exception - if an error occurs during reading from the resource file, writing the response or accessing the configuration files

getRequestURI

protected String getRequestURI(HttpServletRequest pRequest)
Gets the request URI that was used from the client to communicate to the server. It's not always possible to use the request URL from the http request because if mod_proxy was used, the URL may be different to the URL used from the client application! This method takes care of such differences.

Parameters:
pRequest - the client request
Returns:
the connection URL


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.