org.aitools.programd.server.servlet
Class TalkToBotServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.aitools.programd.server.servlet.TalkToBotServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class TalkToBotServlet
extends javax.servlet.http.HttpServlet

Puts a Bot object into the session context (if it isn't there already) so that the user can conduct a conversation with the bot.

Author:
Noel Bush
See Also:
Serialized Form

Field Summary
protected  Core core
          The Core object that will be used throughout.
protected  java.lang.String defaultBotServletPage
          A default bot page if none other is provided.
protected  java.lang.String errorPage
          A page to use for displaying errors.
 
Constructor Summary
TalkToBotServlet()
           
 
Method Summary
 void destroy()
          Removes the reference to the Core, and removes it from the context attributes.
protected  void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Just passes to setupBot(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
protected  void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Just passes to setupBot(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
protected  void forward(java.lang.String page, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void init()
          Gets the Core (should have already been initialized by a listener, or whatever) and keeps a reference to it.
protected  void setupBot(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Creates a Bot object if necessary, puts it in a session attribute, and forwards to a JSP page.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

core

protected Core core
The Core object that will be used throughout.


defaultBotServletPage

protected java.lang.String defaultBotServletPage
A default bot page if none other is provided.


errorPage

protected java.lang.String errorPage
A page to use for displaying errors.

Constructor Detail

TalkToBotServlet

public TalkToBotServlet()
Method Detail

init

public void init()
Gets the Core (should have already been initialized by a listener, or whatever) and keeps a reference to it.

Overrides:
init in class javax.servlet.GenericServlet
See Also:
GenericServlet.init()

destroy

public void destroy()
Removes the reference to the Core, and removes it from the context attributes.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet
See Also:
GenericServlet.destroy()

doGet

protected void doGet(javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse resp)
              throws javax.servlet.ServletException,
                     java.io.IOException
Just passes to setupBot(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).

Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

doPost

protected void doPost(javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      java.io.IOException
Just passes to setupBot(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).

Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

setupBot

protected void setupBot(javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse resp)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Creates a Bot object if necessary, puts it in a session attribute, and forwards to a JSP page.

Parameters:
req - the request
resp - the response
Throws:
javax.servlet.ServletException
java.io.IOException

forward

protected void forward(java.lang.String page,
                       javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse resp)
                throws javax.servlet.ServletException,
                       java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException