Example usage for javax.servlet.http HttpServletRequest getLocales

List of usage examples for javax.servlet.http HttpServletRequest getLocales

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getLocales.

Prototype

public Enumeration<Locale> getLocales();

Source Link

Document

Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.

Usage

From source file:org.springframework.security.web.savedrequest.DefaultSavedRequest.java

@SuppressWarnings("unchecked")
public DefaultSavedRequest(HttpServletRequest request, PortResolver portResolver) {
    Assert.notNull(request, "Request required");
    Assert.notNull(portResolver, "PortResolver required");

    // Cookies//from w  ww .  ja v a 2  s. co m
    addCookies(request.getCookies());

    // Headers
    Enumeration<String> names = request.getHeaderNames();

    while (names.hasMoreElements()) {
        String name = names.nextElement();
        // Skip If-Modified-Since and If-None-Match header. SEC-1412, SEC-1624.
        if (HEADER_IF_MODIFIED_SINCE.equalsIgnoreCase(name) || HEADER_IF_NONE_MATCH.equalsIgnoreCase(name)) {
            continue;
        }
        Enumeration<String> values = request.getHeaders(name);

        while (values.hasMoreElements()) {
            this.addHeader(name, values.nextElement());
        }
    }

    // Locales
    addLocales(request.getLocales());

    // Parameters
    addParameters(request.getParameterMap());

    // Primitives
    this.method = request.getMethod();
    this.pathInfo = request.getPathInfo();
    this.queryString = request.getQueryString();
    this.requestURI = request.getRequestURI();
    this.serverPort = portResolver.getServerPort(request);
    this.requestURL = request.getRequestURL().toString();
    this.scheme = request.getScheme();
    this.serverName = request.getServerName();
    this.contextPath = request.getContextPath();
    this.servletPath = request.getServletPath();
}