ix.util.http
Class HttpStringServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
ix.util.http.HttpObjectServlet
ix.util.http.HttpStringServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- Direct Known Subclasses:
- IServeCommServer.ControlServlet, IServeSLCommServer.SLChatbotTestServlet, IServeSLCommServer.SLNextMessageServlet, IServeSLCommServer.SLRegistrationServelt, IServeSLCommServer.SLReplyServlet, IServeSLCommServer.SLSendServlet
public abstract class HttpStringServlet
- extends HttpObjectServlet
Handles HTTP requests that can be regarded as sending a string
and receiving one in reply.
An HttpStringServelt is like an HttpStringClient
but on the
server side. Where a client sends a string, and receives a string reply,
the servlet receives a string, and sends one back.
At present, only POST requests are supported.
- See Also:
HttpServer
,
Serialized Form
Method Summary |
protected java.lang.String |
decodeReceived(java.lang.String contents)
Turns request contents into an object. |
protected byte[] |
encodeForSend(java.lang.Object obj)
Turns an object into response contents. |
protected java.lang.String |
handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.Object content)
The main part of handling the request. |
protected abstract java.lang.String |
handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.String content)
|
static void |
main(java.lang.String[] argv)
Main program for testing. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, 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 |
HttpStringServlet
public HttpStringServlet()
handleRequest
protected java.lang.String handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.Object content)
throws HttpRequestException
- Description copied from class:
HttpObjectServlet
- The main part of handling the request. The contents have
already been read and turned into an object by calling
HttpObjectServlet.decodeReceived(String)
. The HttpServletRequest
is passed primarily to allow this method to look at the
request headers.
- Specified by:
handleRequest
in class HttpObjectServlet
- Returns:
- the object to encode and send as a response.
- Throws:
HttpRequestException
- to indicate that an error
response should be sent. The status value and message
will be taken from the exception.
handleRequest
protected abstract java.lang.String handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.String content)
throws HttpRequestException
- Throws:
HttpRequestException
encodeForSend
protected byte[] encodeForSend(java.lang.Object obj)
throws java.io.UnsupportedEncodingException
- Description copied from class:
HttpObjectServlet
- Turns an object into response contents.
- Overrides:
encodeForSend
in class HttpObjectServlet
- Throws:
java.io.UnsupportedEncodingException
- See Also:
HttpObjectServlet.decodeReceived(String contents)
decodeReceived
protected java.lang.String decodeReceived(java.lang.String contents)
- Description copied from class:
HttpObjectServlet
- Turns request contents into an object. For example, the
content might be an XML representation of an object.
- Overrides:
decodeReceived
in class HttpObjectServlet
- See Also:
HttpObjectServlet.encodeForSend(Object contents)
main
public static void main(java.lang.String[] argv)
- Main program for testing.