|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--edu.utexas.beg.agi.AGIServlet
The main Servlet for the AGI interactive web pages.
This Servlet is responsible for generating web pages that contain dynamic content,
and for processing parameters submitted by those pages.
Specifically, when an exercise step uses and Applet, then this servlet is
responsible for sending any previous input parameter values to that Applet, either
through Applet parameters, or an I/O request by the Applet.
When an exercise step uses JavaScript- or plainHTML-forms, this Servlet is
solely responsible for streaming the page (which may have dynamic values within it)
and processing the results.
This class uses several helper classes, mostly for the purpose of dividing the source code into logical sections. Everything servlet-related could have been in this one class, but Servlet classes tend to get untidy with too many println()s in them.
LoginHandler
,
DynamicHTMLPage
,
ParameterValidator
, Serialized FormField Summary | |
(package private) DynamicHTMLPage[] |
dynamicPages
Helper Object for streaming mostly-static HTML pages back to the client browser, but substituting initial parameter values where appropriate. |
(package private) LoginHandler |
loginHandler
Helper Object for validating user logins. |
(package private) ParameterValidator |
validator
Helper Object for validating parameters when validation is needed. |
Fields inherited from class javax.servlet.GenericServlet |
config |
Constructor Summary | |
AGIServlet()
|
Method Summary | |
private DynamicHTMLPage[] |
createDynamicHTMLPages()
Called during Servlet initialization to create the list of DynamicHTMLPages that will be served by this Object. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
The main method for handling any HTTP GET request. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
The main method for handling any HTTP POST request. |
private DynamicHTMLPage |
findDynamicHTMLPage(String pagePath)
Searches the array of dynamic page Objects for one to handle the given path. |
private String |
getNextPage(javax.servlet.http.HttpServletRequest request,
UserParameters parameters)
Determines the next page to show the user. |
String |
getServletInfo()
Standard Servlet API method for describing who we are, and what we think we're doing here. |
void |
init(javax.servlet.ServletConfig config)
Initializes this Servlet Object. |
void |
processHTTPRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process an HTTP GET or POST request. |
protected Vector |
processInputParameters(javax.servlet.http.HttpServletRequest request,
UserParameters parameters)
Sets any user input parameters attached to the request as values in the UserParameters Object which is attached to this Session. |
protected void |
returnErrorPage(String error,
String reason,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Generic routine for reporting errors to the client browser when something goes wrong. |
void |
returnLoginPage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Writes the user login page to the client browser. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete,
doHead,
doOptions,
doPut,
doTrace,
getAllDeclaredMethods,
getLastModified,
maybeSetLastModified,
service,
service |
Methods inherited from class javax.servlet.GenericServlet |
destroy,
getInitParameter,
getInitParameterNames,
getServletConfig,
getServletContext,
log |
Methods inherited from class java.lang.Object |
|
Field Detail |
ParameterValidator validator
DynamicHTMLPage[] dynamicPages
LoginHandler loginHandler
Constructor Detail |
public AGIServlet()
Method Detail |
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
Servlets use init() instead of a real constructor.
If a Servlet is database-driven or dependent on some other
being, it would establish connections here, so that in the
event of some failure, it could throw a ServletException, and
our web server would know not to count on us.
This servlet does not have dependencies, so we'll simply create our helper Objects here.
public String getServletInfo()
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
When you type a simple URL, i.e. http://www.jjt.com/index.html
, that
is a GET request. In HTTP, that simply means "GET me this file from this host."
GET requests can also have simple parameters, i.e.
http://www.jjt.com/index.html?myname=Jonathan&mycompany=JJT
. In this
way, parameters can be passed to this Servlet.
The "other" main type of HTTP is a POST. This servlet accepts GET or POST requests, and handles them both in the same manner by calling processHTTPRequest().
request
- the HTTP request received from the client browser.response
- the HTTP reply to be populated by this method.doPost(HttpServletRequest,HttpServletResponse)
,
processHTTPRequest(HttpServletRequest,HttpServletResponse)
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
When you type a simple URL, i.e. http://www.jjt.com/index.html
, that
is a GET request. A slightly more complex request is a POST, which is the way
most HTML forms submit data. The client user fills in the blanks and hits the
"submit" button, and the values of each field are POSTed to the server as
named parameters.
The "other" main type of HTTP is a GET. This servlet accepts GET or POST requests, and handles them both in the same manner by calling processHTTPRequest().
request
- the HTTP request received from the client browser.response
- the HTTP reply to be populated by this method.doGet(HttpServletRequest,HttpServletResponse)
,
processHTTPRequest(HttpServletRequest,HttpServletResponse)
public void processHTTPRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
This method is called when a request comes from a client browser directed at
this Servlet. The request might be in the form:
http://www.beg.utexas.edu/servlets/edu.utexas.beg.agi.AGIServlet?parm1=value1&parm2=value2
This request is presented in the form of a Request Object, which encapsulates
all aspects of the client request, incuding cookie values and the parameters given.
This method should digest the Request and populate the Response Object, which includes
streaming back the HTML code for the next page the client browser will display.
request
- the HTTP request received from the client browser.response
- the HTTP reply to be populated by this method.protected void returnErrorPage(String error, String reason, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
private DynamicHTMLPage[] createDynamicHTMLPages()
public void returnLoginPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
protected Vector processInputParameters(javax.servlet.http.HttpServletRequest request, UserParameters parameters)
private DynamicHTMLPage findDynamicHTMLPage(String pagePath)
private String getNextPage(javax.servlet.http.HttpServletRequest request, UserParameters parameters)
The next page is determined either by the nextpage
parameter of the Request, or, if none is given, by the content of the
UserParameters Object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |