Example usage for javax.servlet.http HttpSession getCreationTime

List of usage examples for javax.servlet.http HttpSession getCreationTime

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getCreationTime.

Prototype

public long getCreationTime();

Source Link

Document

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Usage

From source file:de.innovationgate.wgpublisher.webtml.utils.TMLContext.java

private Object getSessionMetaData(String name) {

    if (!getEnvironment().isPageContextAvailable()) {
        this.setLastError(
                "Cannot retrieve session metadata because this script does not run inside a WebTML page");
        return null;
    }//from   w w w  .  j av a2  s.  c  om

    HttpSession session = gethttpsession();
    if (name.equals("start")) {
        return new Date(session.getCreationTime());
    } else if (name.equals("lastaccess")) {
        return new Date(session.getLastAccessedTime());
    } else if (name.equals("id")) {
        return session.getId();
    } else if (name.equals("language")) {
        return getpreferredlanguage();
    } else {
        return null;
    }
}

From source file:nl.armatiek.xslweb.serializer.RequestSerializer.java

@SuppressWarnings("rawtypes")
private void serializeSession() throws Exception {
    HttpSession session = req.getSession();
    if (session == null) {
        return;// w  w w. j  a va2s  . com
    }
    xsw.writeStartElement(URI, "session");
    dataElement(xsw, URI, "creation-time", getXsDateTimeString(new Date(session.getCreationTime())));
    dataElement(xsw, URI, "id", session.getId());
    dataElement(xsw, URI, "last-accessed-time", getXsDateTimeString(new Date(session.getLastAccessedTime())));
    dataElement(xsw, URI, "max-inactive-interval", Integer.toString(session.getMaxInactiveInterval()));
    dataElement(xsw, URI, "is-new", Boolean.toString(session.isNew()));
    Enumeration attrNames = session.getAttributeNames();
    if (attrNames.hasMoreElements()) {
        xsw.writeStartElement(URI, "attributes");
        while (attrNames.hasMoreElements()) {
            String attrName = (String) attrNames.nextElement();
            xsw.writeStartElement(URI, "attribute");
            xsw.writeAttribute("name", attrName);
            Object attr = session.getAttribute(attrName);
            if (attr instanceof Collection) {
                @SuppressWarnings("unchecked")
                Collection<Attribute> attrs = (Collection<Attribute>) attr;
                for (Attribute a : attrs) {
                    xsw.writeStartElement(URI, "item");
                    if (a.isSerialized()) {
                        xsw.writeAttribute("type", a.getType());
                        getFilteredXMLReader().parse(new InputSource(new StringReader(a.getSerializedValue())));
                    } else {
                        xsw.writeAttribute("type", a.getType());
                        xsw.writeCharacters(a.getValue().toString());
                    }
                    xsw.writeEndElement();
                }
            } else {
                xsw.writeCharacters(attr.toString());
            }
            xsw.writeEndElement();
        }
        xsw.writeEndElement();
    }
    xsw.writeEndElement();
}

From source file:org.apache.tapestry.request.RequestContext.java

/**
 * Writes the state of the context to the writer, typically for inclusion
 * in a HTML page returned to the user. This is useful
 * when debugging.  The Inspector uses this as well.
 *
 **//*from   w ww .  jav a 2 s .com*/

public void write(IMarkupWriter writer) {
    // Create a box around all of this stuff ...

    writer.begin("table");
    writer.attribute("class", "request-context-border");
    writer.begin("tr");
    writer.begin("td");

    // Get the session, if it exists, and display it.

    HttpSession session = getSession();

    if (session != null) {
        object(writer, "Session");
        writer.begin("table");
        writer.attribute("class", "request-context-object");

        section(writer, "Properties");
        header(writer, "Name", "Value");

        pair(writer, "id", session.getId());
        datePair(writer, "creationTime", session.getCreationTime());
        datePair(writer, "lastAccessedTime", session.getLastAccessedTime());
        pair(writer, "maxInactiveInterval", session.getMaxInactiveInterval());
        pair(writer, "new", session.isNew());

        List names = getSorted(session.getAttributeNames());
        int count = names.size();

        for (int i = 0; i < count; i++) {
            if (i == 0) {
                section(writer, "Attributes");
                header(writer, "Name", "Value");
            }

            String name = (String) names.get(i);
            pair(writer, name, session.getAttribute(name));
        }

        writer.end(); // Session

    }

    object(writer, "Request");
    writer.begin("table");
    writer.attribute("class", "request-context-object");

    // Parameters ...

    List parameters = getSorted(_request.getParameterNames());
    int count = parameters.size();

    for (int i = 0; i < count; i++) {

        if (i == 0) {
            section(writer, "Parameters");
            header(writer, "Name", "Value(s)");
        }

        String name = (String) parameters.get(i);
        String[] values = _request.getParameterValues(name);

        writer.begin("tr");
        writer.attribute("class", getRowClass());
        writer.begin("th");
        writer.print(name);
        writer.end();
        writer.begin("td");

        if (values.length > 1)
            writer.begin("ul");

        for (int j = 0; j < values.length; j++) {
            if (values.length > 1)
                writer.beginEmpty("li");

            writer.print(values[j]);

        }

        writer.end("tr");
    }

    section(writer, "Properties");
    header(writer, "Name", "Value");

    pair(writer, "authType", _request.getAuthType());
    pair(writer, "characterEncoding", _request.getCharacterEncoding());
    pair(writer, "contentLength", _request.getContentLength());
    pair(writer, "contentType", _request.getContentType());
    pair(writer, "method", _request.getMethod());
    pair(writer, "pathInfo", _request.getPathInfo());
    pair(writer, "pathTranslated", _request.getPathTranslated());
    pair(writer, "protocol", _request.getProtocol());
    pair(writer, "queryString", _request.getQueryString());
    pair(writer, "remoteAddr", _request.getRemoteAddr());
    pair(writer, "remoteHost", _request.getRemoteHost());
    pair(writer, "remoteUser", _request.getRemoteUser());
    pair(writer, "requestedSessionId", _request.getRequestedSessionId());
    pair(writer, "requestedSessionIdFromCookie", _request.isRequestedSessionIdFromCookie());
    pair(writer, "requestedSessionIdFromURL", _request.isRequestedSessionIdFromURL());
    pair(writer, "requestedSessionIdValid", _request.isRequestedSessionIdValid());
    pair(writer, "requestURI", _request.getRequestURI());
    pair(writer, "scheme", _request.getScheme());
    pair(writer, "serverName", _request.getServerName());
    pair(writer, "serverPort", _request.getServerPort());
    pair(writer, "contextPath", _request.getContextPath());
    pair(writer, "servletPath", _request.getServletPath());

    // Now deal with any headers

    List headers = getSorted(_request.getHeaderNames());
    count = headers.size();

    for (int i = 0; i < count; i++) {
        if (i == 0) {
            section(writer, "Headers");
            header(writer, "Name", "Value");
        }

        String name = (String) headers.get(i);
        String value = _request.getHeader(name);

        pair(writer, name, value);
    }

    // Attributes

    List attributes = getSorted(_request.getAttributeNames());
    count = attributes.size();

    for (int i = 0; i < count; i++) {
        if (i == 0) {
            section(writer, "Attributes");
            header(writer, "Name", "Value");
        }

        String name = (String) attributes.get(i);

        pair(writer, name, _request.getAttribute(name));
    }

    // Cookies ...

    Cookie[] cookies = _request.getCookies();

    if (cookies != null) {
        for (int i = 0; i < cookies.length; i++) {

            if (i == 0) {
                section(writer, "Cookies");
                header(writer, "Name", "Value");
            }

            Cookie cookie = cookies[i];

            pair(writer, cookie.getName(), cookie.getValue());

        } // Cookies loop
    }

    writer.end(); // Request

    object(writer, "Servlet");
    writer.begin("table");
    writer.attribute("class", "request-context-object");

    section(writer, "Properties");
    header(writer, "Name", "Value");

    pair(writer, "servlet", _servlet);
    pair(writer, "name", _servlet.getServletName());
    pair(writer, "servletInfo", _servlet.getServletInfo());

    ServletConfig config = _servlet.getServletConfig();

    List names = getSorted(config.getInitParameterNames());
    count = names.size();

    for (int i = 0; i < count; i++) {

        if (i == 0) {
            section(writer, "Init Parameters");
            header(writer, "Name", "Value");
        }

        String name = (String) names.get(i);
        ;
        pair(writer, name, config.getInitParameter(name));

    }

    writer.end(); // Servlet

    ServletContext context = config.getServletContext();

    object(writer, "Servlet Context");
    writer.begin("table");
    writer.attribute("class", "request-context-object");

    section(writer, "Properties");
    header(writer, "Name", "Value");

    pair(writer, "majorVersion", context.getMajorVersion());
    pair(writer, "minorVersion", context.getMinorVersion());
    pair(writer, "serverInfo", context.getServerInfo());

    names = getSorted(context.getInitParameterNames());
    count = names.size();
    for (int i = 0; i < count; i++) {
        if (i == 0) {
            section(writer, "Initial Parameters");
            header(writer, "Name", "Value");
        }

        String name = (String) names.get(i);
        pair(writer, name, context.getInitParameter(name));
    }

    names = getSorted(context.getAttributeNames());
    count = names.size();
    for (int i = 0; i < count; i++) {
        if (i == 0) {
            section(writer, "Attributes");
            header(writer, "Name", "Value");
        }

        String name = (String) names.get(i);
        pair(writer, name, context.getAttribute(name));
    }

    writer.end(); // Servlet Context

    writeSystemProperties(writer);

    writer.end("table"); // The enclosing border
}

From source file:org.carewebframework.ui.sessiontracker.MainRowRenderer.java

/**
 * @see AbstractRowRenderer#renderRow//from w  ww. ja v a 2s. com
 */
@Override
protected Component renderRow(final Row row, final SessionInfo sInfo) {
    final Session session = sInfo == null ? null : sInfo.getSession();
    final HttpSession nativeSession = session == null ? null : (HttpSession) session.getNativeSession();
    //Because it's possible that the session could be invalidated but yet still in the list
    String sessionId = null;
    String institution = StrUtil.formatMessage("@cwf.sessiontracker.msg.unknown");
    Date creationTime = null;
    Date lastAccessedTime = null;
    int maxInactiveInterval = 0;
    String clientAddress = null;

    try {
        if (nativeSession != null) {
            sessionId = nativeSession.getId();
            creationTime = new Date(nativeSession.getCreationTime());
            lastAccessedTime = new Date(nativeSession.getLastAccessedTime());
            maxInactiveInterval = nativeSession.getMaxInactiveInterval();
            clientAddress = session.getRemoteAddr();
        }
    } catch (final IllegalStateException e) {
        log.warn("The following session was still in the list of activeSessions yet was invalidated: "
                + session);
        return null;
    }

    createCell(row, sessionId);
    createCell(row, clientAddress);
    createCell(row, institution);
    createCell(row, creationTime);
    createCell(row, lastAccessedTime);
    createCell(row, String.valueOf(maxInactiveInterval));
    return sInfo == null || sInfo.getDesktops().isEmpty() ? null : row;
}

From source file:org.codehaus.wadi.web.TestHttpSession.java

public void testRest(Manager manager) {
    long start = System.currentTimeMillis();
    HttpSession session = ((WADIHttpSession) manager.create(null)).getWrapper();
    long end = System.currentTimeMillis();
    assertTrue(session.getSessionContext().getSession(null) == null);
    assertTrue(session.getSessionContext().getIds() != null);
    session.getServletContext(); // cannot really test unless inside a container... - TODO
    assertTrue(session.getCreationTime() >= start && session.getCreationTime() <= end);
    assertTrue(session.getCreationTime() == session.getLastAccessedTime());
}

From source file:org.j2free.util.ServletUtils.java

/**
 * //from www. java 2  s .c  o m
 * @param req
 * @return
 */
public static String describeRequest(HttpServletRequest req) {

    if (req == null) {
        return EMPTY;
    }

    HttpSession session = null;
    try {
        session = req.getSession();
    } catch (Exception e) {
    }

    StringBuilder body = new StringBuilder();
    body.append("Browser: " + req.getHeader("User-Agent"));

    body.append("\n\nRequest Info");
    body.append("\nRequest URI: " + req.getRequestURI());
    body.append("\nRequest URL: " + req.getRequestURL().toString());
    body.append("\nPath Info: " + req.getPathInfo());
    body.append("\nQuery String: " + req.getQueryString());

    if (session != null) {
        body.append("\n\nSession Info");
        body.append("\nSession ID: " + session.getId());
        body.append("\nSession Created: " + new Date(session.getCreationTime()).toString());
        body.append("\nSession Last Accessed: " + new Date(session.getLastAccessedTime()).toString());
    }

    body.append("\n\nUser Info");
    body.append("\nRemote User: " + req.getRemoteUser());
    body.append("\nUser Principal: " + req.getUserPrincipal());

    body.append("\n\nServer Info");
    String hostname = "", serverInstance = "", ip = "";
    try {
        hostname = java.net.InetAddress.getLocalHost().getHostName();
        serverInstance = System.getProperty("com.sun.aas.instanceName");
        ip = java.net.InetAddress.getLocalHost().getHostAddress();
        body.append("\nInstance: " + serverInstance + " : " + ip + " : " + hostname);
    } catch (Exception e) {
    }

    return body.toString();
}

From source file:org.opencustomer.webapp.module.system.sessions.ListAction.java

@Override
public ActionForward execute(ActionMapping mapping, ListForm form, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
    SessionMonitor monitor = (SessionMonitor) request.getSession().getServletContext()
            .getAttribute(Globals.SESSION_MONITOR_KEY);

    if (log.isDebugEnabled())
        log.debug("found " + monitor.getUserSessions().size() + " monitored sessions");

    ArrayList<SessionInfoBean> list = new ArrayList<SessionInfoBean>();
    for (HttpSession session : monitor.getUserSessions()) {
        SessionInfoBean bean = new SessionInfoBean();
        bean.setLoginTime(new Date(session.getCreationTime()));
        bean.setLastAccessTime(new Date(session.getLastAccessedTime()));
        bean.setInactiveTime(System.currentTimeMillis() - session.getLastAccessedTime());
        UserVO user = (UserVO) session.getAttribute(Globals.USER_KEY);
        if (user != null)
            bean.setUsername(user.getUserName());
        list.add(bean);//from ww  w .  ja  v a2  s. co m
    }

    Collections.sort(list, new Comparator<SessionInfoBean>() {
        public int compare(SessionInfoBean bean1, SessionInfoBean bean2) {
            CompareToBuilder builder = new CompareToBuilder();

            builder.append(bean2.getLastAccessTime(), bean1.getLastAccessTime());
            builder.append(bean1.getUsername(), bean2.getUsername());

            return builder.toComparison();
        }
    });

    request.setAttribute("list", list);

    SessionStatisticBean statistic = new SessionStatisticBean();
    for (SessionInfoBean bean : list)
        statistic.add(bean.getInactiveTime() / 1000);

    request.setAttribute("statistic", statistic);

    return mapping.getInputForward();
}

From source file:org.sakaiproject.portal.util.ErrorReporter.java

@SuppressWarnings("rawtypes")
private String requestDisplay(HttpServletRequest request) {
    ResourceBundle rb = rbDefault;
    StringBuilder sb = new StringBuilder();
    try {/*  w w w .j  a v a2 s. c o m*/
        sb.append(rb.getString("bugreport.request")).append("\n");
        sb.append(rb.getString("bugreport.request.authtype")).append(request.getAuthType()).append("\n");
        sb.append(rb.getString("bugreport.request.charencoding")).append(request.getCharacterEncoding())
                .append("\n");
        sb.append(rb.getString("bugreport.request.contentlength")).append(request.getContentLength())
                .append("\n");
        sb.append(rb.getString("bugreport.request.contenttype")).append(request.getContentType()).append("\n");
        sb.append(rb.getString("bugreport.request.contextpath")).append(request.getContextPath()).append("\n");
        sb.append(rb.getString("bugreport.request.localaddr")).append(request.getLocalAddr()).append("\n");
        sb.append(rb.getString("bugreport.request.localname")).append(request.getLocalName()).append("\n");
        sb.append(rb.getString("bugreport.request.localport")).append(request.getLocalPort()).append("\n");
        sb.append(rb.getString("bugreport.request.method")).append(request.getMethod()).append("\n");
        sb.append(rb.getString("bugreport.request.pathinfo")).append(request.getPathInfo()).append("\n");
        sb.append(rb.getString("bugreport.request.protocol")).append(request.getProtocol()).append("\n");
        sb.append(rb.getString("bugreport.request.querystring")).append(request.getQueryString()).append("\n");
        sb.append(rb.getString("bugreport.request.remoteaddr")).append(request.getRemoteAddr()).append("\n");
        sb.append(rb.getString("bugreport.request.remotehost")).append(request.getRemoteHost()).append("\n");
        sb.append(rb.getString("bugreport.request.remoteport")).append(request.getRemotePort()).append("\n");
        sb.append(rb.getString("bugreport.request.requesturl")).append(request.getRequestURL()).append("\n");
        sb.append(rb.getString("bugreport.request.scheme")).append(request.getScheme()).append("\n");
        sb.append(rb.getString("bugreport.request.servername")).append(request.getServerName()).append("\n");
        sb.append(rb.getString("bugreport.request.headers")).append("\n");
        for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
            String headerName = (String) e.nextElement();
            boolean censor = (censoredHeaders.get(headerName) != null);
            for (Enumeration he = request.getHeaders(headerName); he.hasMoreElements();) {
                String headerValue = (String) he.nextElement();
                sb.append(rb.getString("bugreport.request.header")).append(headerName).append(":")
                        .append(censor ? "---censored---" : headerValue).append("\n");
            }
        }
        sb.append(rb.getString("bugreport.request.parameters")).append("\n");
        for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {

            String parameterName = (String) e.nextElement();
            boolean censor = (censoredParameters.get(parameterName) != null);
            String[] paramvalues = request.getParameterValues(parameterName);
            for (int i = 0; i < paramvalues.length; i++) {
                sb.append(rb.getString("bugreport.request.parameter")).append(parameterName).append(":")
                        .append(i).append(":").append(censor ? "----censored----" : paramvalues[i])
                        .append("\n");
            }
        }
        sb.append(rb.getString("bugreport.request.attributes")).append("\n");
        for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) {
            String attributeName = (String) e.nextElement();
            Object attribute = request.getAttribute(attributeName);
            boolean censor = (censoredAttributes.get(attributeName) != null);
            sb.append(rb.getString("bugreport.request.attribute")).append(attributeName).append(":")
                    .append(censor ? "----censored----" : attribute).append("\n");
        }
        HttpSession session = request.getSession(false);
        if (session != null) {
            DateFormat serverLocaleDateFormat = DateFormat.getDateInstance(DateFormat.FULL,
                    Locale.getDefault());
            sb.append(rb.getString("bugreport.session")).append("\n");
            sb.append(rb.getString("bugreport.session.creation")).append(session.getCreationTime())
                    .append("\n");
            sb.append(rb.getString("bugreport.session.lastaccess")).append(session.getLastAccessedTime())
                    .append("\n");
            sb.append(rb.getString("bugreport.session.creationdatetime"))
                    .append(serverLocaleDateFormat.format(session.getCreationTime())).append("\n");
            sb.append(rb.getString("bugreport.session.lastaccessdatetime"))
                    .append(serverLocaleDateFormat.format(session.getLastAccessedTime())).append("\n");
            sb.append(rb.getString("bugreport.session.maxinactive")).append(session.getMaxInactiveInterval())
                    .append("\n");
            sb.append(rb.getString("bugreport.session.attributes")).append("\n");
            for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) {
                String attributeName = (String) e.nextElement();
                Object attribute = session.getAttribute(attributeName);
                boolean censor = (censoredAttributes.get(attributeName) != null);
                sb.append(rb.getString("bugreport.session.attribute")).append(attributeName).append(":")
                        .append(censor ? "----censored----" : attribute).append("\n");
            }

        }
    } catch (Exception ex) {
        M_log.error("Failed to generate request display", ex);
        sb.append("Error " + ex.getMessage());
    }

    return sb.toString();
}

From source file:org.seratic.enterprise.tgestiona.web.filter.AppHttpSessionListener.java

@Override
public void sessionDestroyed(HttpSessionEvent se) {
    Log log = LogFactory.getLog("Aplicacion");
    HttpSession session = se.getSession();
    long now = new java.util.Date().getTime();
    boolean timeout = (now - session.getLastAccessedTime()) >= ((long) session.getMaxInactiveInterval()
            * 1000L);/*from   w w  w  . j av a  2s . c o  m*/
    if (timeout) {
        long duration = new Date().getTime() - session.getCreationTime();
        long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
        long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
        long diffInHours = TimeUnit.MILLISECONDS.toHours(duration);
        SimpleDateFormat formatFechaHora = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        log.info("Sesiones-> Finalizacion automatica de sesion");
        log.info("Sesiones-> Id Sesion: " + session.getId());
        log.info("Sesiones-> Fecha creacion sesion: "
                + formatFechaHora.format(new Date(session.getCreationTime())));
        log.info("Sesiones-> Tiempo conexion sesion, " + diffInHours + " Horas " + diffInMinutes + " Minutos "
                + diffInSeconds + " Segundos.");
        log.info("Sesiones-> Fecha ultima peticion: "
                + formatFechaHora.format(new Date(session.getLastAccessedTime())));
        log.info("Sesiones-> Fecha sesion timeout: " + formatFechaHora
                .format(new Date(session.getLastAccessedTime() + session.getMaxInactiveInterval() * 1000)));
    }
}

From source file:org.wings.session.WingServlet.java

public final SessionServlet getSessionServlet(HttpServletRequest request, HttpServletResponse response,
        boolean createSessionServlet) throws ServletException {
    final HttpSession httpSession = request.getSession(true);

    // it should be enough to synchronize on the http session object...
    synchronized (httpSession) {
        SessionServlet sessionServlet = null;

        if (httpSession != null) {
            sessionServlet = (SessionServlet) httpSession.getAttribute(lookupName);
        }/*from   w  ww.j a  v  a 2  s  .c o  m*/

        // Sanity check - maybe this is a stored/deserialized session servlet?
        if (sessionServlet != null && !sessionServlet.isValid()) {
            sessionServlet.destroy();
            sessionServlet = null;
        }

        /*
         * we are only interested in a new session, if the response is
         * not null. If it is null, then we just called getSessionServlet()
         * for lookup purposes and are satisfied, if we don't get anything.
         */
        if (sessionServlet == null) {
            if (createSessionServlet) {
                log.info("no session servlet, create new one");
                sessionServlet = newSession(request, response);
                httpSession.setAttribute(lookupName, sessionServlet);
            } else {
                return null;
            }
        }

        if (log.isDebugEnabled()) {
            StringBuilder message = new StringBuilder().append("session id: ")
                    .append(request.getRequestedSessionId()).append(", created at: ")
                    .append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                            .format(new java.util.Date(httpSession.getCreationTime())))
                    .append(", identified via:")
                    .append(request.isRequestedSessionIdFromCookie() ? " cookie" : "")
                    .append(request.isRequestedSessionIdFromURL() ? " URL" : "").append(", expiring after: ")
                    .append(httpSession.getMaxInactiveInterval()).append("s ");
            log.debug(message.toString());
            //log.debug("session valid " + request.isRequestedSessionIdValid());
            //log.debug("session httpsession id " + httpSession.getId());
            //log.debug("session httpsession new " + httpSession.isNew());
            //log.debug("session last accessed at " +
            //        new java.util.Date(httpSession.getLastAccessedTime()));
            //log.debug("session expiration timeout (s) " +
            //        httpSession.getMaxInactiveInterval());
            //log.debug("session contains wings session " +
            //        (httpSession.getAttribute(lookupName) != null));
        }

        sessionServlet.getSession().getExternalizeManager().setResponse(response);

        /* Handling of the requests character encoding.
         * --------------------------------------------
         * The following block is needed for a correct handling of
         * non-ISO-8859-1 data:
         *
         * Using LocaleCharacterSet and/or charset.properties we can
         * advise the client to use i.e. UTF-8 as character encoding.
         * Once told the browser consequently also encodes his requests
         * in the choosen characterset of the sings session. This is
         * achieved by adding the HTML code
         * <meta http-equiv="Content-Type" content="text/html;charset="<charset>">
         * to the generated pages.
         *
         * If the user hasn't overridden the encoding in their browser,
         * then all form data (e.g. mueller) is submitted with data encoded
         * like m%C3%BCller because byte pair C3 BC is how the german
         * u-umlaut is represented in UTF-8. If the form is
         * iso-8859-1 encoded then you get m%FCller, because byte FC is
         * how it is presented in iso-8859-1.
         *
         * So the browser behaves correctly by sending his form input
         * correctly encoded in the advised character encoding. The issue
         * is that the servlet container is typically unable to determine
         * the correct encoding of this form data. By proposal the browser
         * should als declare the used character encoding for his data.
         * But actual browsers omit this information and hence the servlet
         * container is unable to guess the right encoding (Tomcat actually
         * thenalways guesses ISO 8859-1). This results in totally
         * scrumbled up data for all non ISO-8859-1 character encodings.
         * With the block below we tell the servlet container about the
         * character encoding we expect in the browsers request and hence
         * the servlet container can do the correct decoding.
         * This has to be done at very first, otherwise the servlet
         * container will ignore this setting.
         */
        if ((request.getCharacterEncoding() == null)) { // was servlet container able to identify encoding?
            try {
                String sessionCharacterEncoding = sessionServlet.getSession().getCharacterEncoding();
                // We know better about the used character encoding than tomcat
                log.debug("Advising servlet container to interpret request as " + sessionCharacterEncoding);
                request.setCharacterEncoding(sessionCharacterEncoding);
            } catch (UnsupportedEncodingException e) {
                log.warn("Problem on applying current session character encoding", e);
            }
        }

        return sessionServlet;
    }
}