Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials


 

 

Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java I18n Internationalization Using Struts With O, Struts Strutsinternationalization

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

;
 
Java Examples for Beginners
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (post your own) View All Comments Latest 10 Comments:

java i18n internationalization using struts with options drop down list.

generate the localedemo.jsp file as

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:html locale="true">
<body bgcolor=pink>
<form name="language" action="Locale1" method="POST">


<select name="language">
<option value="en">English</option>
<option value="de">German</option>
<option value="fr">French</option>
</select>
<p>




</P>

<table border="1">

<tbody>
<tr>
<td><bean:message key="user.name" /></td>
<td><input type="text" name="username" value="" /></td>
</tr>
<tr>
<td><bean:message key="password.name" /></td>
<td><input type="text" name="password" value="" /></td>
</tr>
<td><input type="submit" value="<bean:message key="submit.name" />" /></td>


<tr> </tr>
</tbody>
</table>


<%--
<bean:message key="index.info" />
--%>
</form>
</body>
</html:html>


and write the servlet file(java file)locale1.java as


/*
* Locale1.java
*
* Created on April 19, 2007, 5:25 PM
*/

import java.io.*;
import java.net.*;
import java.util.Locale;

import javax.servlet.*;
import javax.servlet.http.*;

/**
*
* @author Javeed
* @version
*/
public class Locale1 extends HttpServlet {

/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();

String formLanguage = request.getParameter("language");
Locale newLanguage = new Locale(formLanguage, "US");
Locale.setDefault(newLanguage);
HttpSession hs = request.getSession();
hs.setAttribute("org.apache.struts.action.LOCALE", newLanguage);
response.sendRedirect("localedemo.jsp");

}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}

use the two .properties files like ApplicationResourse.properties and ApplicationResourse_de.properties (ApplicationResourse_xx.properties format files only)

/*
* Locale1.java
*
* Created on April 19, 2007, 5:25 PM
*/

import java.io.*;
import java.net.*;
import java.util.Locale;

import javax.servlet.*;
import javax.servlet.http.*;

/**
*
* @author Javeed
* @version
*/
public class Locale1 extends HttpServlet {

/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();

String formLanguage = request.getParameter("language");
Locale newLanguage = new Locale(formLanguage, "US");
Locale.setDefault(newLanguage);
HttpSession hs = request.getSession();
hs.setAttribute("org.apache.struts.action.LOCALE", newLanguage);
response.sendRedirect("localedemo.jsp");

}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}


Javeed M R
javeed.mca@gmail.com

Posted by Javeed M R on Thursday, 04.19.07 @ 19:30pm | #14576

Ask programming questions?

 

 

Back to Tutorial
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name

 

 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.