W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 1999

additional Information on strange Servlet behavior

From: Manfred Knobloch <manne@diff.uni-tuebingen.de>
Date: Tue, 2 Feb 1999 09:06:03 -0500 (EST)
Message-id: <fc.000f4a01000447ea000f4a01000447ea.447f1@diff.uni-tuebingen.de>
To: www-jigsaw@w3.org, szeiger@novocode.com
Hi,

the following Servlet (sample from the o'reilly book)  increments the
visit-counter on reload and works well with apache mod_jserv 0.9.11, 
jsdk20 servletrunner on SuSe Linux Kernel 2.0.35, compiled with jdk1.1.6


(apache 1.3 + mod_jserv - ok)
http://chagall.diff.uni-tuebingen.de/servlet/SessionTracker

(servletrunner - ok)
http://chagall.diff.uni-tuebingen.de:8080/servlets/SessionTracker

(jigsaw 2.0.1 - no incrementing)
http://chagall.diff.uni-tuebingen.de:8001/servlets/SessionTracker


(netforge 0.48 - asks for cookie accept on each reload)
http://chagall.diff.uni-tuebingen.de:22722/servlet/SessionTracker


the code
--------------------------------------------------------------------------

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SessionTracker extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    // Get the current session object, create one if necessary
    HttpSession session = req.getSession(true);

    Integer count = (Integer)session.getValue("tracker.count");
    if (count == null)
      count = new Integer(1);
    else
      count = new Integer(count.intValue() + 1);
    session.putValue("tracker.count", count);

    out.println("<HTML><HEAD><TITLE>SessionTracker</TITLE></HEAD>");
    out.println("<BODY><H1>Session Tracking Demo</H1>");

    out.println("You've visited this page " + count +
      ((count.intValue() == 1) ? " time." : " times."));

    out.println("<P>");

    out.println("<H2>Here is your session data:</H2>");
    String nS = new String((session.isNew() ? "NEU" : "ALT"));

    out.println("Session ist  " + nS + "<BR>");
    String[] names = session.getValueNames();
    for (int i = 0; i < names.length; i++) {
      out.println(names[i] + ": " + session.getValue(names[i]) + "<BR>");
    }
    out.println("</BODY></HTML>");
    out.close();
  }
}
------------------------------------------------------------------------


TIA 


Manfred Knobloch

Kompetenzzentrum für Multimedia und Telematik
am DIFF
Konrad Adenauer Str. 40
72072 Tübingen

tel: ++49 (0)7071 / 979 232
fax: ++49 (0)7071 / 979 322
email: manfred_knobloch@diff.uni-tuebingen.de
Received on Tuesday, 2 February 1999 09:11:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:28 GMT