FileDocCategorySizeDatePackage
CurrLocaleServlet.javaAPI DocExample1300Fri Aug 08 06:19:24 BST 2003com.jspservletcookbook

CurrLocaleServlet

public class CurrLocaleServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    
    //Get the client's Locale
   Locale locale = request.getLocale();
   ResourceBundle bundle = ResourceBundle.getBundle("i18n.WelcomeBundle",locale);
   String welcome =  bundle.getString("Welcome");
   
   NumberFormat nft = NumberFormat.getCurrencyInstance(locale);
   String formatted = nft.format(1000000);
   
   //Display the locale
      response.setContentType("text/html");
      java.io.PrintWriter out = response.getWriter();
      out.println("<html><head><title>"+welcome+"</title></head><body>");
      
      out.println("<h2>"+bundle.getString("Hello") + " " +
        bundle.getString("and") + " " +
          welcome+"</h2>");
      
      
      out.println("Locale: ");
      out.println( locale.getLanguage()+"_"+locale.getCountry() );
      
      out.println("<br /><br />");
      out.println(formatted);
      
      out.println("</body></html>");
      out.close();