All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sdi.wap.SiteImpl

java.lang.Object
   |
   +----javax.servlet.GenericServlet
           |
           +----javax.servlet.http.HttpServlet
                   |
                   +----com.sdi.wap.SiteImpl

public abstract class SiteImpl
extends HttpServlet
implements Site
Abstract superclass to define inheritable methods for concrete Site implementations. Each servlet context must provide one (and only one) subclass of this class. The use of static variables below requires that each site class reside in a its own servlet context. This restriction may be removed in the future.

Author:
Brad Cox

Variable Index

 o accountAttributeName
The name of the session attribute that is reserved to hold the Account of the currently logged in user.
 o doAttributeName
This is the name of the request parameter that will contain the identifier of the currently executing page.
 o toAttributeName

Constructor Index

 o SiteImpl()
Constructor.

Method Index

 o doGet(HttpServletRequest, HttpServletResponse)
Service get requests by forwarding them to the post request processor
 o doPost(HttpServletRequest, HttpServletResponse)
Service post requests.
 o doRequest(HttpServletRequest, HttpServletResponse)
Process a servlet Request
 o getAccount(View)
get the currently logged in account from the accountAttributeName session attribute
 o getBaseDirectory()
Get the base directory (document root) of the html server.
 o getContextName()
Get the context name for this site.
 o getDefaultPage()
Return this site's default page.
 o getLoginPage()
Return this site's login page.
 o getRefusePage()
Return the page that should handle permission denied problems
 o htmlPage(View, String)
Emit the argument string to the browser enclosed in htmlPageOpen() and htmlPageClose() output.
 o htmlPageClose(View)
Return this site's convention for closing a web page typically "  o htmlPageOpen(View)
Return this site's convention for closing a web page as a bare minimum, "whatever"
 o htmlParameters(HttpServletRequest)
Returns a string representing the names and values of all request parameters.
 o init(ServletConfig)
Initializes the servlet by calling super.init(servletConfig), then calling page.checkUrl() for each of the site's StaticPages in order to log any undefined urls in the log file.
 o main(String[])
Insert the method's description here.
 o setAccount(Account, View)
Set the currently logged in account by storing it in a session attribute

Variables

 o doAttributeName
 private static final String doAttributeName
This is the name of the request parameter that will contain the identifier of the currently executing page. This is occasionally useful in general, but its main client is in htmlPageOpen() implementations that build navigational menus according to which page is being displayed.

 o toAttributeName
 private static final String toAttributeName
 o accountAttributeName
 protected static final String accountAttributeName
The name of the session attribute that is reserved to hold the Account of the currently logged in user. This is managed internally and should need no external attention other than to avoid using this attribute for other purposes.

Constructors

 o SiteImpl
 public SiteImpl()
Constructor. A no args constructor is required by the servlet protocol.

Methods

 o doGet
 public void doGet(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException
Service get requests by forwarding them to the post request processor

Overrides:
doGet in class HttpServlet
 o doPost
 public void doPost(HttpServletRequest request,
                    HttpServletResponse response) throws ServletException, IOException
Service post requests. The request parameter, whose name is defined in nextPageParameterName, determines the name of the DynamicPage that the browser has requested. This method looks up the DynamicPage by name. If not found, it throws an Exception. If it is found, the currently logged in account is retrieved from the session attribute, and the Page's role is tested for Role.Null, which marks pages that can be accessed without logging in. If the role is not Role.Null, the account is tested to determine if it is authorized to access this page. If not the request is forwarded to site.getRefusePage(). If all is well, page's launch method is called, which constructs a State instance for responding to this request and calls the resulting state's controller() method.

Overrides:
doPost in class HttpServlet
See Also:
Page, State, Site
 o doRequest
 public void doRequest(HttpServletRequest request,
                       HttpServletResponse response) throws ServletException, IOException
Process a servlet Request

Parameters:
request - javax.servlet.http.HttpServletRequest
response - javax.servlet.http.HttpServletResponse
 o getAccount
 public Account getAccount(View view) throws SessionExpiredException
get the currently logged in account from the accountAttributeName session attribute

 o getBaseDirectory
 public abstract String getBaseDirectory()
Get the base directory (document root) of the html server.

Returns:
java.lang.String
 o getContextName
 public abstract String getContextName()
Get the context name for this site.

Returns:
java.lang.String
 o getDefaultPage
 public abstract DynamicPage getDefaultPage()
Return this site's default page. This is the page to display if the requested page cannot be located or if no page identifier is specified in the request. A good choice to return from this method is the site's login page.

 o getLoginPage
 public abstract DynamicPage getLoginPage()
Return this site's login page.

 o getRefusePage
 public abstract DynamicPage getRefusePage()
Return the page that should handle permission denied problems

 o htmlPage
 public String htmlPage(View view,
                        String contents) throws Exception
Emit the argument string to the browser enclosed in htmlPageOpen() and htmlPageClose() output.

Parameters:
View - view: the State that is issuing the request.
String - contents: html text for the page contents.
 o htmlPageClose
 public abstract String htmlPageClose(View view)
Return this site's convention for closing a web page typically "
Parameters:
View - view: the execution context
Returns:
String
 o htmlPageOpen
 public abstract String htmlPageOpen(View view) throws Exception
Return this site's convention for closing a web page as a bare minimum, "whatever"

Parameters:
View - view: the execution context
Returns:
String
 o htmlParameters
 protected static final String htmlParameters(HttpServletRequest request) throws IOException
Returns a string representing the names and values of all request parameters. This is called by doRequest() to log the request parameters as a debug aid.

Parameters:
HttpServletRequest - request
Returns:
String
 o init
 public void init(ServletConfig servletConfig) throws UnavailableException
Initializes the servlet by calling super.init(servletConfig), then calling page.checkUrl() for each of the site's StaticPages in order to log any undefined urls in the log file.

Overrides:
init in class GenericServlet
 o main
 public static void main(String args[])
Insert the method's description here. Creation date: (01/22/01 15:46:43)

Parameters:
args - java.lang.String[]
 o setAccount
 public void setAccount(Account account,
                        View view)
Set the currently logged in account by storing it in a session attribute

Parameters:
Account - account: the account object to save as the current account for this session
View - view: the current servlet context. This is used to locate the session object.

All Packages  Class Hierarchy  This Package  Previous  Next  Index