FileDocCategorySizeDatePackage
JSPLocaleNegotiatorServlet.javaAPI DocExample1930Wed Jan 17 20:18:56 GMT 2001None

JSPLocaleNegotiatorServlet.java

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

public class JSPLocaleNegotiatorServlet extends HttpServlet {

  private static final String defaultJSP = "/jsp/default_en_US.jsp";
  private static final String jspExtension = ".jsp";

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

    Locale usersLocale = request.getLocale();

    StringBuffer jspWithLocale = new StringBuffer();
    if (request.getParameter("jsppage") != null) {
      jspWithLocale.append(request.getParameter("jsppage"));
      jspWithLocale.append("_");
      jspWithLocale.append(usersLocale.toString());
      jspWithLocale.append(jspExtension);
    } else
      jspWithLocale.append(defaultJSP);

    response.setLocale(usersLocale);
    getServletConfig().getServletContext().getRequestDispatcher(jspWithLocale.toString()).forward(request,response);
  }
}
*/

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

public class JSPLocaleNegotiatorServlet extends HttpServlet {

  private static final String defaultJSP = "/jsp/default_en_US.jsp";
  private static final String jspExtension = ".jsp";

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

    Locale usersLocale = request.getLocale();

    StringBuffer jspWithLocale = new StringBuffer();
    if (request.getParameter("jsppage") != null) {
      jspWithLocale.append(request.getParameter("jsppage"));
      jspWithLocale.append("_");
      jspWithLocale.append(usersLocale.toString());
      jspWithLocale.append(jspExtension);
    } else
      jspWithLocale.append(defaultJSP);

    response.setLocale(usersLocale);
    getServletConfig().getServletContext()
        .getRequestDispatcher(jspWithLocale.toString())
        .forward(request,response);
  }
}