edu.utexas.its.eis.tools.qwicap.servlet
Class Context

java.lang.Object
  extended by edu.utexas.its.eis.tools.qwicap.servlet.Context

public class Context
extends Object

Context provides a few utility methods, as well as convenient access to hit-specific information, like the HttpServletRequest and HttpServletResponse objects. Most of the time, Qwicap applications won't need this class, but you can obtain the current instance of it by invoking the Qwicap.getContext() method.

Author:
Chris W. Johnson

Method Summary
 File getExistingFile(String FileName)
          Returns a File object corresponding to the specified file (or directory), if it exists.
 URL getExistingResource(String ResourceName)
          Returns the URL for a resource supplied by the servlet container, for instance an HTML file within your web application.
 File getFile(String FileName)
          Returns a File object corresponding to the specified file (or directory), which may, or may not, exist.
 HttpServletRequest getRequest()
          Returns the current HttpServletRequest instance.
 URL getResource(String ResourceName)
          Returns the URL for a resource supplied by the servlet container, for instance an HTML file within your web application.
 HttpServletResponse getResponse()
          Returns the current HttpServletResponse instance.
 QwicapServlet getServlet()
          Returns the current HttpServlet instance.
 Object getSessionAttribute(String Name)
          If your web application is using session attributes, use this method to retrieve them, in order to avoid naming conflicts.
 void removeSessionAttribute(String Name)
          If your web application is using session attributes, use this method to remove them, in order to avoid naming conflicts.
 void setSessionAttribute(String Name, Object Value)
          If your web application is using session attributes, use this method to set them, in order to avoid naming conflicts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getServlet

public QwicapServlet getServlet()
Returns the current HttpServlet instance.

Returns:
The current HttpServlet.

getRequest

public HttpServletRequest getRequest()
Returns the current HttpServletRequest instance.

Returns:
The current HttpServletRequest.

getResponse

public HttpServletResponse getResponse()
Returns the current HttpServletResponse instance.

Returns:
The current HttpServletResponse.

getFile

public File getFile(String FileName)
             throws FileNotFoundException
Returns a File object corresponding to the specified file (or directory), which may, or may not, exist.

Parameters:
FileName - The name/path of a local file.
Returns:
A File object corresponding to the specified local file, whether it actually exists, or not.
Throws:
FileNotFoundException
See Also:
getExistingFile(java.lang.String)

getExistingFile

public File getExistingFile(String FileName)
                     throws FileNotFoundException
Returns a File object corresponding to the specified file (or directory), if it exists. If it does not exist, a FileNotFoundException is thrown. The message in that exception will state the file/path that was requested, and the absolute path of the location where this method believed the file would be found.

Parameters:
FileName - The name/path of the local file that the caller asserts must exist.
Returns:
A File object corresponding to the specified local file, if the file exists.
Throws:
FileNotFoundException - If the file does not exist.

getResource

public URL getResource(String ResourceName)
                throws MalformedURLException
Returns the URL for a resource supplied by the servlet container, for instance an HTML file within your web application. The name must begin with a slash character ('/'), so, if you wanted the URL for a file named "index.html" located at the top level of your web application, you would pass the string "/index.html".

Parameters:
ResourceName - The name/path of the resource to be supplied by the servlet container.
Returns:
The URL of the resource supplied by the servlet container, or null if the resource could not be found.
Throws:
MalformedURLException - If ResourceName does not begin with a slash character ('/'), or if more conventional URL formation rules have somehow been violated.
See Also:
ServletContext.getResource(java.lang.String)

getExistingResource

public URL getExistingResource(String ResourceName)
                        throws FileNotFoundException,
                               MalformedURLException
Returns the URL for a resource supplied by the servlet container, for instance an HTML file within your web application. The name must begin with a slash character ('/'), so, if you wanted the URL for a file named "index.html" located at the top level of your web application, you would pass the string "/index.html".

Parameters:
ResourceName - The name/path of the resource to be supplied by the servlet container.
Returns:
The URL of the resource supplied by the servlet container.
Throws:
MalformedURLException - If ResourceName does not begin with a slash character ('/'), or if more conventional URL formation rules have somehow been violated.
FileNotFoundException - If the requested resource could not be found.
See Also:
ServletContext.getResource(java.lang.String)

getSessionAttribute

public Object getSessionAttribute(String Name)
If your web application is using session attributes, use this method to retrieve them, in order to avoid naming conflicts.

Parameters:
Name - The name of the session attribute to be retrieved.
Returns:
The value of the session attribute.

setSessionAttribute

public void setSessionAttribute(String Name,
                                Object Value)
If your web application is using session attributes, use this method to set them, in order to avoid naming conflicts.

Parameters:
Name - The name of the session attribute to be retrieved.
Value - The value of the session attribute.

removeSessionAttribute

public void removeSessionAttribute(String Name)
If your web application is using session attributes, use this method to remove them, in order to avoid naming conflicts.

Parameters:
Name - The name of the session attribute to be removed.