Tynamo™-TINI
v1.0.4

com.qindesign.servlet.example
Class SimpleOneWireServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.qindesign.servlet.example.SimpleOneWireServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class SimpleOneWireServlet
extends HttpServlet

Simple servlet that reads from a 1-Wire sensor. This assumes the adapter and device address are known.

Version:
1.0.4
Author:
Shawn Silverman
See Also:
Serialized Form

Constructor Summary
SimpleOneWireServlet()
           
 
Method Summary
protected  void doGet(HttpServletRequest req, HttpServletResponse resp)
          Process a GET request.
protected  Object getValue(DSPortAdapter a, OneWireContainer c, HttpServletRequest req, HttpServletResponse resp)
          Retrieves a value from the given container.
protected  void printMessage(HttpServletResponse resp, Object msg)
          Prints the output message.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, 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
 

Constructor Detail

SimpleOneWireServlet

public SimpleOneWireServlet()
Method Detail

doGet

protected void doGet(HttpServletRequest req,
                     HttpServletResponse resp)
              throws ServletException,
                     IOException
Process a GET request.

Overrides:
doGet in class HttpServlet
Throws:
ServletException
IOException

printMessage

protected void printMessage(HttpServletResponse resp,
                            Object msg)
                     throws IOException
Prints the output message. The message could be a string, number, or any other object. The content type and other necessary headers in the response should be set.

Parameters:
resp - the HTTP response object
msg - an object containing the message
Throws:
IOException

getValue

protected Object getValue(DSPortAdapter a,
                          OneWireContainer c,
                          HttpServletRequest req,
                          HttpServletResponse resp)
                   throws OneWireIOException,
                          OneWireException
Retrieves a value from the given container. This simple implementation only reads values from temperature, humidity, and clock containers.

Parameters:
a - the port adapter, for exclusive calls, etc.
c - the 1-Wire container object
req - the HTTP request object, for extracting request parameters, etc.
resp - the HTTP response object, for setting the status, if needed, etc.
Throws:
OneWireIOException
OneWireException

Tynamo™-TINI
v1.0.4

© 2001-2007 Shawn Silverman