org.zkoss.zk.au.http
Class DHtmlUpdateServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by 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 (see Desktop.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). The extension0 parameter specifies the first AU extension, the extension1 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
DHtmlUpdateServlet()
           
 
Method Summary
 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 before DHtmlUpdateServlet is started.
 void denoteSessionTimeout(WebApp wapp, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean compress)
          Denote HTTP 410 Session timeout response
 void 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
 
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
 

Constructor Detail

DHtmlUpdateServlet

public DHtmlUpdateServlet()
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 class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.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

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 before DHtmlUpdateServlet 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)

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

getLastModified

protected long getLastModified(javax.servlet.http.HttpServletRequest request)
Overrides:
getLastModified in class javax.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 class javax.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 class javax.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 if getDesktop(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


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo