FileDocCategorySizeDatePackage
LocaleInformationServlet.javaAPI DocExample1891Wed Jan 17 20:18:12 GMT 2001None

LocaleInformationServlet.java

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

public class LocaleInformationServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      IOException, ServletException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    Locale userPreferredLocale = request.getLocale();
    Enumeration userPreferredLocales = request.getLocales();

    out.println("<html>");
    out.println("<title>LocaleInformationServlet</title>");
    out.println("<body>");
    out.println("Preferred Locale: " + userPreferredLocale.toString());
    out.println("<br>");
    out.print("Preferred Locales: ");

    while (userPreferredLocales.hasMoreElements()) {
      userPreferredLocale = (Locale)userPreferredLocales.nextElement();
      out.print(userPreferredLocale.toString() + ", ");
    }
    out.println();
    out.println("</body></html>");
  }
}
*/

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

public class LocaleInformationServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      IOException, ServletException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    Locale userPreferredLocale = request.getLocale();
    Enumeration userPreferredLocales = request.getLocales();

    out.println("");
    out.println("");
    out.println("");
    out.println("Preferred Locale: " + userPreferredLocale.toString());
    out.println("");
    out.print("Preferred Locales: ");

    while (userPreferredLocales.hasMoreElements()) {
      userPreferredLocale = (Locale)userPreferredLocales.nextElement();
      out.print(userPreferredLocale.toString() + ", ");
    }
    out.println();
    out.println("");
  }
}