Hi List,

I'm somewhat new to servlets and all, but managed to get
to run a small trial webapp (chat-like) using Tomcat 3.2:

Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2;
Java 1.3.0; Linux 2.2.16 i386; java.vendor=Sun Microsystems Inc.)


Simplified, I have a class like this:

public class Receiver extends HttpServlet {

  // ...

  public void doGet(HttpServletRequest rq, HttpServletResponse rs) 
        throws IOException, ServletException 
    {
        rs.setBufferSize(0);
        rs.setContentType("text/html");
        PrintWriter out = rs.getWriter();
        makeHead(out);
        out.println("<P>Chat Receiver</P>\n");
        rs.flushBuffer();
        while (! terminate) {
            // log("in main loop", new Exception("-"));  // Line 57
            synchronized(writeCond) {
                try {
                    writeCond.wait();
                } catch (InterruptedException ie) {
                    // theContext.log("Receiver interrupted while waiting for text.");
                }
            }
            // theContext.log("write cond fired!", new Exception("-"));
            synchronized(writeLock) {
                out.print(writeMessage.toString());
                rs.flushBuffer();
                writeMessage.setLength(0);
            }
            // theContext.log("wrote received text", new Exception("-"));
        }
        out.println("</BODY></HTML>");
    }

---

Unfortunately, the first log(...) call fails with a NullPointerException
if uncommented:

java.lang.NullPointerException
        at nop.Receiver.doGet(Receiver.java:57)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
        at org.apache.tomcat.core.Handler.service(Handler.java:286)
        at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at 
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at 
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
        at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
        at java.lang.Thread.run(Thread.java:484)

---

What could be wrong here? As far as I understand, Servlet.log(java.lang.String)
should write a log entry to the server log file. How come it doesn't?

-- 
Best regards,

Ansgar W. Konermann

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to