if (firstRequest) response.setDateHeader("Expires", 1000); firstRequest = false;
    public final synchronized void doGet(HttpServletRequest req,                                         HttpServletResponse response)        throws ServletException, IOException    {        SessionManager.setSession(session);        session.setServletRequest(req);        session.setServletResponse(response);        TimeMeasure measure = null;        if (logger.isLoggable(Level.FINER)) {                    measure = new TimeMeasure(new MessageFormat("{0}: {1} {2}"));        }        // in case, the previous thread did not clean up.        SForm.clearArmedComponents();        Device outputDevice = null;        try {            /*             * The tomcat 3.x has a bug, in that it does not encode the URL             * sometimes. It does so, when there is a cookie, containing some             * tomcat sessionid but that is invalid (because, for instance,             * we restarted the tomcat in-between).              * [I can't think of this being the correct behaviour, so I assume             *  it is a bug. ]             *             * So we have to workaround this here: if we actually got the             * session id from a cookie, but it is not valid, we don't do             * the encodeURL() here: we just leave the requestURL as it is             * in the properties .. and this is url-encoded, since             * we had set it up in the very beginning of this session              * with URL-encoding on  (see WingServlet::newSession()).             *             * Vice versa: if the requestedSessionId is valid, then we can             * do the encoding (which then does URL-encoding or not, depending             * whether the servlet engine detected a cookie).             * (hen)             */            RequestURL requestURL = null;            if (req.isRequestedSessionIdValid()) {                 requestURL = new RequestURL("", getSessionEncoding(response));                // this will fire an event, if the encoding has changed ..                ((PropertyService)session).setProperty("request.url",                                                        requestURL);            }            if (logger.isLoggable(Level.FINER)) {                logger.finer("RequestURL: " + requestURL);                logger.finer("\nHEADER:");                for (Enumeration en = req.getHeaderNames(); en.hasMoreElements();) {                    String header = (String)en.nextElement();                    logger.finer("   " + header + ": " + req.getHeader(header));                }                logger.finer("");            }            handleLocale(req);            if (logger.isLoggable(Level.FINER)) {                measure.start("time to dispatch");            }                        Enumeration en = req.getParameterNames();                        // are there parameters/low level events to dispatch             if ( en.hasMoreElements() ) {                // only fire DISPATCH_START if we have parameters to dispatch                session.fireRequestEvent(SRequestEvent.DISPATCH_START);                                while (en.hasMoreElements()) {                    String paramName = (String)en.nextElement();                    String[] value = req.getParameterValues(paramName);                    logger.fine("dispatching " + paramName + " = " + value[0]);                                        session.getDispatcher().dispatch(paramName, value);                }                if (logger.isLoggable(Level.FINER)) {                    measure.stop();                    measure.start("time to fire form events");                }                            SForm.fireEvents();                            // only fire DISPATCH DONE if we have parameters to dispatch                session.fireRequestEvent(SRequestEvent.DISPATCH_DONE);            }                                    if (logger.isLoggable(Level.FINER)) {                measure.stop();                measure.start("time to process request");            }                        // if the user chose to exit the session as a reaction on an            // event, we got an URL to redirect after the session.            /*             * where is the right place?             * The right place is              *    - _after_ we processed the events              *        (e.g. the 'Pressed Exit-Button'-event or gave             *         the user the chance to exit this session in the custom             *         processRequest())             *    - but _before_ the rendering of the page,             *      because otherwise an redirect won't work, since we must             *      not have sent anything to the output stream).             */            if (session.getRedirectAddress() != null) {                req.getSession().invalidate(); // calls destroy implicitly                if (session.getRedirectAddress().length() > 0) {                    // redirect to user requested URL.                    response.sendRedirect(session.getRedirectAddress());                }                else {                    // redirect to a fresh session.                    response.sendRedirect(HttpUtils.getRequestURL(req)                                          .toString());                }                return;            }                        // invalidate frames and resources            getSession().getReloadManager().invalidateResources();                        // deliver resource. The            // externalizer is able to handle static and dynamic resources            ExternalizeManager extManager = getSession().getExternalizeManager();            String pathInfo = req.getPathInfo().substring(1);            logger.fine("pathInfo: " + pathInfo);                        /*             * if we have no path info, or the special '_' path info             * (that should be explained somewhere, Holger), then we             * deliver the toplevel Frame of this application.             */            String externalizeIdentifier = null;            if (pathInfo == null                || pathInfo.length() == 0                 || "_".equals(pathInfo)                 || firstRequest) {                logger.fine("delivering default frame");                firstRequest = false;                                if (session.frames().size() == 0)                    throw new ServletException("no frame visible");                                // get the first frame from the set and walk up the hierarchy.                // this should work in most cases. if there are more than one                // toplevel frames, the developer has to care about the resource                // ids anyway ..                SFrame defaultFrame = (SFrame)session.frames().iterator().next();                while (defaultFrame.getParent() != null)                    defaultFrame = (SFrame)defaultFrame.getParent();                                Resource resource = defaultFrame.getDynamicResource(DynamicCodeResource.class);                externalizeIdentifier = resource.getId();            }            else {                externalizeIdentifier = pathInfo;            }                        // externalized this resource.            ExternalizedResource extInfo = extManager                .getExternalizedResource(externalizeIdentifier);            if (extInfo != null) {                outputDevice = DeviceFactory.createDevice(extInfo);                //outputDevice = createOutputDevice(req, response, extInfo);                session.fireRequestEvent(SRequestEvent.DELIVER_START, extInfo);                extManager.deliver(extInfo, response, outputDevice);                session.fireRequestEvent(SRequestEvent.DELIVER_DONE, extInfo);            }                        if (logger.isLoggable(Level.FINER)) {                measure.stop();                logger.finer(measure.print());                measure.reset();            }        }        catch (Throwable e) {            logger.log(Level.SEVERE, "exception: ", e);            handleException(req, response, e);        }        finally {            if (outputDevice != null) {                try { outputDevice.close(); } catch (Exception e) {}            }            getSession().getReloadManager().clear();            // make sure that the session association to the thread is removed            // from the SessionManager            SessionManager.removeSession();        }    }