package javax.servlet.http; import josx.rcxcomm.*; import java.io.*; /** * * Provides an abstract class to be subclassed to create * an HTTP servlet suitable for a lejos Web Server. A subclass of * HttpServlet must override at least one method. * * The only method currently suported by lejos is: * * * * lejos currently supports a single Servlet. You call the parameterless * constructor to create the Servlet, and call th inti() method to * start the Web Server. It loops forever processing GET * requests. * * All paths are mapped onto this single servlet. * * @author Lawrie Griffiths * **/ public abstract class HttpServlet { private static final int MAX_PATH = 16; private static final int MAX_QUERY_STRING = 32; private static final int MAX_STRING = 32; private char [] tempChars = new char[MAX_STRING]; private String path = new String(tempChars, 0, MAX_PATH); private String queryString = new String(tempChars, 0, MAX_QUERY_STRING); private char [] pathChars = StringUtils.getCharacters(path); private char [] queryStringChars = StringUtils.getCharacters(queryString); private int pathLength; private int queryStringLength; /** * Initialize the HTTP servlet * * @exception IOException if an input or output error occurs * **/ public void init() throws IOException { RCXPort port = new RCXPort(); InputStream is = port.getInputStream(); OutputStream os = port.getOutputStream(); HttpServletRequest req = new HttpServletRequest(); HttpServletResponse resp = new HttpServletResponse(os); while (true) { byte b = 0, lastB = 0, lastB2 = 0, lastB3; pathLength = 0; queryStringLength = 0; int i; port.reset(); // reset sequence numbers // Skip the get for (i= 0;i<4;i++) is.read(); // Get the path for(i = 0;i