Class AbstractRemoteServiceServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
- Direct Known Subclasses:
RemoteServiceServlet
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected ThreadLocal
<javax.servlet.http.HttpServletRequest> protected ThreadLocal
<javax.servlet.http.HttpServletResponse> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
doPost
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Standard HttpServlet method: handle the POST.protected void
Override this method to control what should happen when an exception escapes thedoPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
method.protected final String
Returns the strong name of the permutation, as reported by the client that issued the request, ornull
if it could not be determined.protected final javax.servlet.http.HttpServletRequest
Gets theHttpServletRequest
object for the current call.protected final javax.servlet.http.HttpServletResponse
Gets theHttpServletResponse
object for the current call.protected void
onAfterRequestDeserialized
(RPCRequest rpcRequest) Override this method to examine the deserialized version of the request before the call to the servlet method is made.protected abstract void
processPost
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Called bydoPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
for type-specific processing of the request.protected String
readContent
(javax.servlet.http.HttpServletRequest request) Override this method in order to control the parsing of the incoming request.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
-
Field Details
-
perThreadRequest
-
perThreadResponse
-
-
Constructor Details
-
AbstractRemoteServiceServlet
public AbstractRemoteServiceServlet()
-
-
Method Details
-
doPost
public final void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Standard HttpServlet method: handle the POST. Delegates toprocessPost(HttpServletRequest, HttpServletResponse)
. This doPost method swallows ALL exceptions, logs them in the ServletContext, and returns a GENERIC_FAILURE_MSG response with status code 500.- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
-
doUnexpectedFailure
Override this method to control what should happen when an exception escapes thedoPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
method. The default implementation will log the failure and send a generic failure response to the client.An "expected failure" is an exception thrown by a service method that is declared in the signature of the service method. These exceptions are serialized back to the client, and are not passed to this method. This method is called only for exceptions or errors that are not part of the service method's signature, or that result from SecurityExceptions, SerializationExceptions, or other failures within the RPC framework.
Note that if the desired behavior is to both send the GENERIC_FAILURE_MSG response AND to rethrow the exception, then this method should first send the GENERIC_FAILURE_MSG response itself (using getThreadLocalResponse), and then rethrow the exception. Rethrowing the exception will cause it to escape into the servlet container.
- Parameters:
e
- the exception which was thrown
-
getPermutationStrongName
Returns the strong name of the permutation, as reported by the client that issued the request, ornull
if it could not be determined. This information is encoded in the "X-GWT-Permutation" HTTP header. -
getThreadLocalRequest
protected final javax.servlet.http.HttpServletRequest getThreadLocalRequest()Gets theHttpServletRequest
object for the current call. It is stored thread-locally so that simultaneous invocations can have different request objects. -
getThreadLocalResponse
protected final javax.servlet.http.HttpServletResponse getThreadLocalResponse()Gets theHttpServletResponse
object for the current call. It is stored thread-locally so that simultaneous invocations can have different response objects. -
onAfterRequestDeserialized
Override this method to examine the deserialized version of the request before the call to the servlet method is made. The default implementation does nothing and need not be called by subclasses.- Parameters:
rpcRequest
-
-
processPost
protected abstract void processPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Throwable Called bydoPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
for type-specific processing of the request. BecausedoPost
swallows allThrowables
, this method may throw any exception the implementor wishes.- Throws:
Throwable
-
readContent
protected String readContent(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException, IOException Override this method in order to control the parsing of the incoming request. For example, you may want to bypass the check of the Content-Type and character encoding headers in the request, as some proxies re-write the request headers. Note that bypassing these checks may expose the servlet to some cross-site vulnerabilities. Your implementation should comply with the HTTP/1.1 specification, which includes handling both requests which include a Content-Length header and requests utilizingTransfer-Encoding: chuncked
.- Parameters:
request
- the incoming request- Returns:
- the content of the incoming request encoded as a string.
- Throws:
javax.servlet.ServletException
IOException
-