xmlBlaster 1.6.2 API

org.xmlBlaster.protocol.http.ajax
Class AjaxServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.xmlBlaster.protocol.http.ajax.AjaxServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class AjaxServlet
extends javax.servlet.http.HttpServlet

This servlet supports requests from a browser, it queries the topic given by "gpsTopicId" configuration which needs to contain GPS coordinates (published for example by a PDA).

Use xmlBlaster/demo/http/gps.html to display the coordinates in a map.

Callback messages are send as xml to the browser:
 <xmlBlasterResponse>
  <update>
    <qos>...</qos>
    <key>...</key>
    <content>...</content>
  </update>
 </xmlBlasterResponse>
 

Author:
Marcel Ruff xmlBlaster@marcelruff.info 2007
See Also:
Serialized Form

Field Summary
private  java.util.Map blasterInstanceMap
          key is the browser sessionId
private static java.util.logging.Logger log
           
private  int maxInactiveInterval
           
private  java.util.Properties props
           
private static long serialVersionUID
           
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
AjaxServlet()
           
 
Method Summary
 void destroy()
           
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           ServletSessionTimeout according to specification: The default timeout period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 boolean get(javax.servlet.http.HttpServletRequest req, java.lang.String key, boolean defaultVal)
           
 int get(javax.servlet.http.HttpServletRequest req, java.lang.String key, int defaultVal)
           
 long get(javax.servlet.http.HttpServletRequest req, java.lang.String key, long defaultVal)
           
private  BlasterInstance getBlasterInstance(javax.servlet.http.HttpServletRequest req)
           
 BlasterInstance[] getBlasterInstances()
           
 java.lang.String getInfo(javax.servlet.http.HttpServletRequest req)
           
 java.lang.String getInfo(javax.servlet.http.HttpServletRequest req, boolean more, boolean all)
           
 java.lang.String getServletInfo()
           
 void init(javax.servlet.ServletConfig conf)
           
 void log(java.lang.String text)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

private static java.util.logging.Logger log

props

private java.util.Properties props

maxInactiveInterval

private int maxInactiveInterval

blasterInstanceMap

private java.util.Map blasterInstanceMap
key is the browser sessionId

Constructor Detail

AjaxServlet

public AjaxServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

getInfo

public java.lang.String getInfo(javax.servlet.http.HttpServletRequest req)

getInfo

public java.lang.String getInfo(javax.servlet.http.HttpServletRequest req,
                                boolean more,
                                boolean all)

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException
 ServletSessionTimeout according to specification:
 The default timeout period for sessions is defined by the servlet container and
	can be obtained via the getMaxInactiveInterval method of the HttpSession
	interface. This timeout can be changed by the Developer using the
	setMaxInactiveInterval method of the HttpSession interface. The timeout
	periods used by these methods are defined in seconds. By definition, if the timeout
	period for a session is set to -1, the session will never expire.
 

We have set the maxInactiveInterval to 1800 sec in web.xml (30 min):

If no Ajax call arrives after the given timeout the servlet-session dies, as a browser user may choose to halt NMEA updates we must set this to a high enough value.

The web.xml setting <session-config> 30 </session-config> is overwritten by our maxInactiveInterval

Test: http://localhost:8080/watchee/ajax?ActionType=request&task=getRawPhoto&locationPictureId=5823&random=0.6236216717670112

Throws:
javax.servlet.ServletException
java.io.IOException

get

public boolean get(javax.servlet.http.HttpServletRequest req,
                   java.lang.String key,
                   boolean defaultVal)

get

public long get(javax.servlet.http.HttpServletRequest req,
                java.lang.String key,
                long defaultVal)

get

public int get(javax.servlet.http.HttpServletRequest req,
               java.lang.String key,
               int defaultVal)

getBlasterInstance

private BlasterInstance getBlasterInstance(javax.servlet.http.HttpServletRequest req)
                                    throws XmlBlasterException
Throws:
XmlBlasterException

getServletInfo

public java.lang.String getServletInfo()

getBlasterInstances

public BlasterInstance[] getBlasterInstances()

destroy

public void destroy()

log

public void log(java.lang.String text)

xmlBlaster 1.6.2 API

Copyright © 1999-2007 The xmlBlaster.org contributers.