Solutions Products Services

Search
Download Contact Us
Documentation Site map
Support About Us
E-commerce SolutionsiPlanet



Localization of Web Modules

You can localize iPlanet Application Server web modules using Forte for Java. In this section, you will create an application that will ask the user's prefered language and name and display "hello" message in the prefered language.

Making the web application display in a new language, other than the languge it was initially developed on, involves 3 separate tasks. First, I18N support must be enabled on iPlanet Application Server. Second, you need to write the application to output in a new language, including creating localized JSP pages for existing JSP pages. Third, ias-web.xml deployment descriptor should be updated.

Enabling I18N support on iPlanet Application Server

To use built-in support for internationalization, you must turn it on first. The detailed information of this topic can be found in Administrator's Guide book of iPlanet Application Server. In this subsection, you will use the Administration Tool to enable the internationalization support. To enable it:

  1. From the Explorer window, select the Runtime tab.
  2. Select to expand the Server Registry node and Installed Servers node.
  3. if the iPlanet Application Server node is not displayed under the Installed Servers node, then the integration modules is not installed or it is not enabled.

  4. Right click on the iPlanet Application Server 6.5 node to display context menu and select the Launch Admin Tool option.
  5. Select the iAS1 node in the Administrator Tool.
  6. Check the Enable I18N Support checkbox.
  7. If you have enabled I18N Support during the installation, the checkbox should already be checked when you selected the iAS1 node. In this case, you may close the Administration Tool window and skip the rest of steps in this subsection.

  8. Select Apply Changes button.
  9. You will be prompted to restart the iPlanet Application Server.

  10. Select OK to dismiss the dialog.
  11. On a Solaris system, navigate to the iASInstallDir\ias\bin\ path, and run the following two scripts:
  12. iascontrol kill -instance -user -password -host -port
    iascontrol start -instance -user -password -host -port

    On Windows, run the following two commands:

    iascontroll kill
    iascontrol start

    iPlanet Application Server will now stop and start again.

    Creating a Localized Web Application

    You will now create an web application that prints hello in English and Japanese. The application consists of four files. The first page, named Hello2.jsp, asks for the prefered language and the user's name. When users select the submit button, a servlet, named Hello2Servlet, receives the request and redirects it to either LocalHello.jsp or LocalHello_ja.jsp depending on the language specified. As the name suggets, LocalHello_ja.jsp will output the Japanese greeting.

    The files will be included in the web module that was created in the Creating a JavaServer Page section of this tutorial. To create the application:

    1. Create Hello2.jsp in the D:\MyWebModules\WebModule directory.
    2. See Creating a JavaServer Page for details.

    3. Change the Hello2.jsp to as follows:
    4. <%@page contentType="text/html"%>
      <html>
      <head><title>JSP Page</title></head>
      <body>
      <h2>Multilingual</h2>
      <FORM ACTION="servlet/myPackage/Hello2Servlet" METHOD="post" NAME="Form1">
      Select preferred language: <br>
      <SELECT NAME="locale" SIZE="3">
      <OPTION selected value="">None</OPTION>
      <OPTION          value="en">English</OPTION>
      <OPTION          value="ja">Japanese</OPTION>
      </SELECT><br><br>
      Enter your name:<br>
      <input TYPE="text" NAME="name" SIZE="30">
      <input TYPE="SUBMIT" NAME="ok" VALUE="submit">
      </FORM>
      </body>
      </html>
      
    5. Save the Hello2 page with File | Save from the menu.
    6. Create Hello2Servlet.java in the WEB-INF/Classes/myPackage node.
    7. Change the processRequest method as follows:
    8. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
         String locale = request.getParameter("locale");
         String name = request.getParameter("name");
         request.setAttribute("name", name);
         com.kivasoft.util.GX.SetLocale(locale);
         RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/LocalHello.jsp");
         dispatcher.forward(request, response);
      } 
      
    9. Save Hello2Servlet.java with File | Save from the menu.
    10. From the File menu, select Mount Filesystem...
    11. Select Add JAR File and select the Browse... button.
    12. Navigate to the iASInstallDir\ias\classes\java\ directory and select kfcjdk11.jar. Select OK to close the dialog window.
    13. The com.kivasoft.util.GX package, used in the processRequest method in Hello2Servlet.java, is included in kfcjdk11.jar. The JAR file is mounted so that the servlet can be compiled in the IDE.

    14. Click OK to mount the JAR file.
    15. Create LocalHello.jsp in the D:\MyWebModules\WebModule directory.
    16. This JSP page will output a message in the English language.

    17. Change the LocalHello.jsp as follows:
    18. <%@page contentType="text/html; charset=UTF8"%>
      <html>
      <head><title>English Hello Page</title></head>
      <body>
      <p><h2>Hello, <%= request.getAttribute("name") %>!</h2></p>
      </body>
      </html>
      
    19. Save LocalHello.jsp with File | Save from the menu.
    20. The page must be saved in UTF-8 encoding.

    21. Create LocalHello_ja.jsp in the D:\MyWebModules\WebModule directory.
    22. This JSP page will output a message in the Japanese language.

    23. Change the LocalHello_ja.jsp as follows:
    24.  


      You can download the code by right-clicking on the code above and selecting Save Link As...

    25. Save LocalHello_ja.jsp with File | Save from the menu.
    26. The page must be saved in UTF-8 encoding.

    Updating the Deployment Descriptor

    In this subsection, you will specify English as a default language and choose UTF8 as an encoding scheme for both Japanese and English languages in the deployment descriptor. To update the deployment descriptor:

    1. Expand WEB-INF node.
    2. Right click on the web.xml node, and select Properties from the Context munu.
    3. In the Properties of the web.xml dialog window, select the iPlanet AS tab.
    4. Select the button for Locale Charet Map field.
    5. Select the Add button.
    6. Select en for Locale and UTF8 for Charset.
    7. Select OK to dismiss the dialog window.
    8. Select the Add button again.
    9. Select ja for Locale and UTF8 for Charset.
    10. Select OK to dismiss the dialog window.
    11. The Property Editor: Locale Charset Map window should contain the two entries you just created.

    12. Select OK.
    13. In the Properties of the web.xml dialog window, select en for Default locale.
    14. Close the window.

    Deploying and Running the Application

    Now, the application is ready to be deployed and run.

    1. Right click on WEB-INF node, and select Deploy from the context menu.
    2. Right click on the Hello2 JSP node in the Explorer window, and select Execute.
    3. The browser opens to the http://serverinstance/NASApp/WebModule/Hello2.jsp URL.
    4. If you select None for the preferred language and submit your name, you will see the greeting in English as it was selected to be the default locale. If you select Japanese, the browser displays the greeting in Japanese, as shown below. You might have to configure the system before the Japanese characters are displayed properly.

    The next step in the iPlanet Application Server Integration Module Tutorial is creating a session Enterprise Java Bean.

     
       

    Legal Notices


    Search