Servlet i18n samples

Please select Sample:

Please select Encoding:




Details

Format Date as per browser's locale
Gets the locale information from browser settings and sets the locale to response object using res.setLocale() method. To run this sample, select desired encoding for the characters you want to use and select “Format Date as per browser's locale” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Including a servlet from another servlet
Includes a servlet using RequestDispatcher's include method. To run this sample, select desired encoding for the characters you want to use and select “Include a servlet” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Forwarding a request to servlet from another servlet
Forwards a servlet using RequestDispatcher's forward method. To run this sample, select desired encoding for the characters you want to use and select “Forward Servlet” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Send localized error message
Send localized error messages using response's sendError method. To run this sample, select desired encoding for the characters you want to use and select “Send error message” from the drop down list. Enter your name (in desired language) on the following screen and click Submit. The entered characters appear in the error message.

Set character encoding
Sets request's character encoding using setCharacterEncoding method of HttpServletRequest interface. This is a new functionality that is being added in Servlet 2.3 Specification . The method setCharacterEncoding is required by the web container to set the encoding for the request object. To run this sample, select desired encoding for the characters you want to use and select “Set Character Encoding” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Using resource bundles
Load resource bundle based on client's locale. This sample provides LocalStrings.properties and LocalStrings_ja.properties files. To verify that the LocalStrings_ja.properties file is loading properly, change your browser's language settings to “ja”. To run this sample, select desired encoding for the characters you want to use and select “Using resource bundles” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Forwarding a request to jsp
Forwards request from servlet to jsp using RequestDispatcher's forward method. To run this sample, select desired encoding for the characters you want to use and select “Forward request to jsp” from the drop down list. Enter your name (in desired language) on the following screen and click Submit.

Back to sample home

Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved.