|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
ix.util.http.HttpObjectServlet
public abstract class HttpObjectServlet
Handles HTTP requests that can be regarded as sending an object and receiving one in reply. The usual I-X XML encoding is used; however, it's possible to change that in a subclass.
An HttpObjectServelt is like an HttpObjectClient but on
the server side: where a client sends an object as XML, and receives
an object as XML in reply, the servlet receives an object as XML,
and sends one back.
At present, only POST requests are supported.
HttpServer,
XMLTranslator,
Serialized Form| Field Summary | |
|---|---|
protected java.lang.String |
responseCharsetName
|
protected java.lang.String |
responseContentType
|
protected HttpUtilities |
util
|
| Constructor Summary | |
|---|---|
HttpObjectServlet()
|
|
| Method Summary | |
|---|---|
protected java.lang.Object |
decodeReceived(java.lang.String contents)
Turns request contents into an object. |
protected void |
describeRequest(javax.servlet.http.HttpServletRequest req)
Utility method that produces debugging output that describes the request. |
protected void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Handle an HTTP POST request. |
protected byte[] |
encodeForSend(java.lang.Object contents)
Turns an object into response contents. |
protected abstract java.lang.Object |
handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.Object received)
The main part of handling the request. |
static void |
main(java.lang.String[] argv)
Main program for testing. |
protected java.lang.String |
readRequest(javax.servlet.http.HttpServletRequest req)
Utility method that reads the request's contents and returns it as a string. |
protected void |
sendResponse(byte[] bytes,
javax.servlet.http.HttpServletResponse resp)
Utility method that writes the response contents. |
void |
setResponseCharsetName(java.lang.String name)
Set the character set used when sending a response. |
void |
setResponseContentType(java.lang.String type)
Set the Content-Type used when sending a response. |
| 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 |
| Field Detail |
|---|
protected HttpUtilities util
protected java.lang.String responseContentType
protected java.lang.String responseCharsetName
| Constructor Detail |
|---|
public HttpObjectServlet()
| Method Detail |
|---|
public void setResponseContentType(java.lang.String type)
public void setResponseCharsetName(java.lang.String name)
protected void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletjavax.servlet.ServletException
java.io.IOExceptionprotected void describeRequest(javax.servlet.http.HttpServletRequest req)
protected java.lang.String readRequest(javax.servlet.http.HttpServletRequest req)
throws HttpRequestException,
java.io.IOException
HttpRequestException
java.io.IOExceptionprotected java.lang.Object decodeReceived(java.lang.String contents)
encodeForSend(Object contents)
protected abstract java.lang.Object handleRequest(javax.servlet.http.HttpServletRequest req,
java.lang.Object received)
throws HttpRequestException
decodeReceived(String). The HttpServletRequest
is passed primarily to allow this method to look at the
request headers.
HttpRequestException - to indicate that an error
response should be sent. The status value and message
will be taken from the exception.
protected byte[] encodeForSend(java.lang.Object contents)
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptiondecodeReceived(String contents)
protected void sendResponse(byte[] bytes,
javax.servlet.http.HttpServletResponse resp)
throws java.io.IOException
java.io.IOExceptionpublic static void main(java.lang.String[] argv)
HttpServer
and adds an HttpObjectServlet (subclass) for path "/take";
the servlet acts as a SafeLispInterpreter for the objects
it's sent. Each object that's received is treated as an
expression and evaluated; the result is sent back as the reply.
The http-server-port parameter can be used to say
what port the server should use.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||