Class DHtmlUpdateServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.zkoss.zk.au.http.DHtmlUpdateServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class DHtmlUpdateServlet extends javax.servlet.http.HttpServlet
Used to receive command from the server and send result back to client. Though it is called DHtmlUpdateServlet, it is used to serve all kind of HTTP-based clients, including ajax (HTML+Ajax), mil (Mobile Interactive Language), and others (seeDesktop.getDeviceType()
.Init parameters:
- compress
- It specifies whether to compress the output if the browser supports the compression (Accept-Encoding).
- extension0, extension1...
- It specifies an AU extension (
AuExtension
). Theextension0
parameter specifies the first AU extension, theextension1
parameter the second AU extension, and so on.
The syntax of the value is
/prefix=class
By default: there are three extensions are associated with "/upload", "/view" and "/dropupload" (see
addAuExtension(org.zkoss.zk.ui.WebApp, java.lang.String, org.zkoss.zk.au.http.AuExtension)
. Also, "/web" is reserved. Don't associate to any AU extension.- Author:
- tomyeh
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DHtmlUpdateServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AuExtension
addAuExtension(java.lang.String prefix, AuExtension extension)
Adds an AU extension and associates it with the specified prefix.static AuExtension
addAuExtension(WebApp wapp, java.lang.String prefix, AuExtension extension)
Adds an AU extension and associates it with the specified prefix, even beforeDHtmlUpdateServlet
is started.void
denoteSessionTimeout(WebApp wapp, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean compress)
Denote HTTP 410 Session timeout responsevoid
destroy()
protected void
doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected void
doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
AuExtension
getAuExtension(java.lang.String prefix)
Returns the AU extension associated with the specified prefix, or null if no AU extension associated.static AuExtension
getAuExtension(WebApp wapp, java.lang.String prefix)
Returns the AU extension that is associated the specified prefix.protected Desktop
getDesktop(Session sess, java.lang.String dtid)
Returns the desktop of the specified ID, or null if not found.protected long
getLastModified(javax.servlet.http.HttpServletRequest request)
static DHtmlUpdateServlet
getUpdateServlet(WebApp wapp)
Returns the update servlet of the specified application, or null if not loaded yet.void
init()
boolean
isCompress()
void
process(Session sess, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean compress)
Process asynchronous update requests from the client.protected Desktop
recoverDesktop(Session sess, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebAppCtrl wappc, java.lang.String dtid)
Recovers the desktop if possible.void
setCompress(boolean compress)
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service, service
-
-
-
-
Method Detail
-
getUpdateServlet
public static DHtmlUpdateServlet getUpdateServlet(WebApp wapp)
Returns the update servlet of the specified application, or null if not loaded yet. Note: if the update servlet is not loaded, it returns null.- Since:
- 3.0.2
-
init
public void init() throws javax.servlet.ServletException
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Servlet
- Overrides:
destroy
in classjavax.servlet.GenericServlet
-
isCompress
public boolean isCompress()
-
setCompress
public void setCompress(boolean compress)
-
getAuExtension
public static final AuExtension getAuExtension(WebApp wapp, java.lang.String prefix)
Returns the AU extension that is associated the specified prefix.- Since:
- 5.0.0
-
getAuExtension
public AuExtension getAuExtension(java.lang.String prefix)
Returns the AU extension associated with the specified prefix, or null if no AU extension associated.- Since:
- 5.0.0
-
addAuExtension
public static final AuExtension addAuExtension(WebApp wapp, java.lang.String prefix, AuExtension extension) throws javax.servlet.ServletException
Adds an AU extension and associates it with the specified prefix, even beforeDHtmlUpdateServlet
is started.Unlike
addAuExtension(String, AuExtension)
, it can be called even if the update servlet is not loaded yet (getUpdateServlet(org.zkoss.zk.ui.WebApp)
returns null).If there was an AU extension associated with the same name, the the old AU extension will be replaced.
- Throws:
javax.servlet.ServletException
- Since:
- 5.0.0
-
addAuExtension
public AuExtension addAuExtension(java.lang.String prefix, AuExtension extension) throws javax.servlet.ServletException
Adds an AU extension and associates it with the specified prefix.If there was an AU extension associated with the same name, the the old AU extension will be replaced.
If you want to add an Au extension, even before DHtmlUpdateServlet is started, use
addAuExtension(WebApp, String, AuExtension)
instead.- Parameters:
prefix
- the prefix. It must start with "/", but it cannot be "/" nor "/web" (which are reserved).extension
- the AU extension (never null).- Returns:
- the previous AU extension associated with the specified prefix, or null if the prefix was not associated before.
- Throws:
javax.servlet.ServletException
- Since:
- 5.0.0
- See Also:
addAuExtension(WebApp,String,AuExtension)
-
getLastModified
protected long getLastModified(javax.servlet.http.HttpServletRequest request)
- Overrides:
getLastModified
in classjavax.servlet.http.HttpServlet
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
java.io.IOException
-
denoteSessionTimeout
public void denoteSessionTimeout(WebApp wapp, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean compress) throws javax.servlet.ServletException, java.io.IOException
Denote HTTP 410 Session timeout response- Throws:
javax.servlet.ServletException
java.io.IOException
- Since:
- 6.5.2
-
process
public void process(Session sess, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean compress) throws javax.servlet.ServletException, java.io.IOException
Process asynchronous update requests from the client.- Throws:
javax.servlet.ServletException
java.io.IOException
- Since:
- 3.0.0
-
getDesktop
protected Desktop getDesktop(Session sess, java.lang.String dtid)
Returns the desktop of the specified ID, or null if not found. If null is returned,recoverDesktop(org.zkoss.zk.ui.Session, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.zkoss.zk.ui.sys.WebAppCtrl, java.lang.String)
will be invoked.- Parameters:
sess
- the session (never null)dtid
- the desktop ID to look for- Since:
- 5.0.3
-
recoverDesktop
protected Desktop recoverDesktop(Session sess, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebAppCtrl wappc, java.lang.String dtid)
Recovers the desktop if possible. It is called ifgetDesktop(org.zkoss.zk.ui.Session, java.lang.String)
returns null.The default implementation will look for any failover manager (
FailoverManager
) is registered, and forward the invocation to it if found.- Returns:
- the recovered desktop, or null if failed to recover
- Since:
- 5.0.3
-
-