Welcome=welcome to en use users


Abc-it-IT. properties

Welcome=welcome to it IT users


Abc-it-IN. properties

Welcome=welcome to it IN users 





<from method=”post ”action=”/i18n”>


<tr><td>select language</tr><td> select country </td></tr>


< select name=”language”>

<option value=”en”> English</option>

< option value=”it”> Italian</option >

< option value=”hi”> Hindi</option >




<select name=”country”>

<option value”us”> numerical<10prion>

<option value”it”> Itali<10prion>

<option value”in”> India<10prion>



<tr><td><input type=”submit” value=”SUBMITLY”>




I18N Sevlet java -

Package com. soft;

Import java. text.*;

Import java. util.*;

Import java. servlet. servlet exception;

Import java. servlet. servlet annotation. Web servlet;

Import java. servlet. http*;

@web servlet(“/i18n”)

Public class I18N servlet extends http servlet


Protected void dopost(http servlet request)request,

Http servletResponse response throws servlet exception,



String language=request. getparameter(“language”);

String country=request. getparameter(“country”);

Locale I = new loaf(Language, country);

Number format nf=number format. Getinstance(i);

Date format df= data format.getDataInstance (o,l);

Resource bundle rb= ResourceBundle .getBundle(“abc” ,l);

Print writer out= response. GetWriter();

Out. println(“<html>”)

Out. println(“<body>”)

Out. println(“<h1>”)

Out. println(“number:”+nf. format(1345.2345)+”<br>”);

Out. println(“date:”+nf. format(new date())+”<br>”);

Out. println(“message:”+rb. Get string(“welcome”));

Out. println(“</h1></body></html>”);

}catch(Exception e){

e.print stack trace();





  • If we use the above approach to provid II8N Support then every time user has to specify lang country, it is not suggestible in web applications.
  • To overcome the above problems, we have to provide I18N Support with out depending on the user, by getting client browser provided language setup
  • When we submit a request from a client browser then browser provided lang will be send to server in the from at “accept lang” request header, here it we get “accept-language” request header value then it is possible to identify from which local the request is coming, with this, we are able to provide I18N Support without specifying lang & country by the user
  • To get a particular request header value, we have to use the following method from servlet request, public string get header (String header-name)
  • Public class I18N Servlet extends Http servlet{ = IL; Protected void do Get(Http Servlet Request request, Http Servlef Response response) Throws servlet Exception, Ioexception{


String locate=request. get header(“accept-language”);

String Tokenizer st= new string tokenizer(local, “-”);

Int count= st. count tokens();

Local i=null;

If (count==1){

String token();

I=new locale (c lang);



String lang=st. next token();

String country=st. next token();

I=new locale (c lang, country);



String lang=st. next token();

String country=st. next token();

String sys-var=st. next token();

I=new locale (lang, country), sys-var);


Number Format nt=number formal, get Insurance(l);




Abc-en. properties

Header1=Durga software solutions

Header2=Registration Form

Sid=student Id

Sname=student Name

Semail=email id

Smobile=contact no


Success=student registration success

Failure=student registration failure


Abc-it. Properties

Header1=Durga software solutions

Header2=Registration Form

Sid=student Id

Sname=student Name

Semail=email id

Smobile=contact no


Success=student registration success

Failure=student registration failure


Abc-te. Properties

Header1= software solutions

Header2=Darakstu patram

Sid=vidyardu Gurdimpu snkya

Sname= vidyardi peru

Semail= vidyuth samachara Gurthimlu

Smobile= sampradimpu sankya


Success=Vidyardi Darakastu safalamayinadhi

Failure= Vidyardi Darakastu cifalamayinadhi



<!Doctype html public11413c11D+D HTML 4.01

Transitional //EN”””>



<meta http-equiv=”Refresh”

Content=”2:URL=http://local host:1010/I18napp/registrationform.dss”>

<title>insert title here</title>



<h1>Application IS Loading….</h1>





<%@Page language=”java”content type=”text/html;

Charset=ISO-8859-1”page encoding=”ISO-8859-1”>


<%@taglib prefix=”f”url=






<meta http-equiy=”content-type ”content=”text/html;


<title>insert title here</title >





<h:panelGrid columns=”2”>

<h:output text value=”#{msg.sid}”/>

<h:input text id=”sid” value=”#{regBean.sid}”/>

<h: output text value=”#{msg. sname}”/>

<h:input text id=”s name” value=”#{reg Bean. S name }”/>

<h: output text value=”#{msg. s name}”/>

<h:input text id=”s email” value=”#{reg Bean. S email }”/>

<h: output text value=”#{msg. s mobile}”/>

<h:input text id=”s mobile” value=”#{reg Bean. S mobile}”/>

<h:command button value =”#{msg.button}”action”#{ reg Bean. registration}”/>






Success. Jsp

<%@page language=”java” content type=”text/html,

Charset=ISO-8859-1”page encoding=”ISO-8859-“%>

<%@taglib prefix=”f”>


</Doc type>



<meta http-equiy=”content-type ”content=”text/html;

<title>Insert title here</ title >




<h1><h:output text value=”#{msg. success}”/></h1>










<meta http-equiy=”content-type

<h1><h:output text value=”#{msg.failure}”/></her>





Package com. soft;

Import java. util locate;

Import javax. faces. component. UIview Root;

Import javax. faces. context. Faces context;

Public class Registration bean{

Private string sid;

Private string sname;

Private string semail;

Private string smobile;

-   ----           --    - getter()setter()

Public string registration(){

String status=””;

If (sid. starts with(“DSS-”)){





Return status;


Public string get Registration form(){

Return” Registration form”;





<?xml version=”1.0”encoding=”UTF-8”?>





< managed-bean -name>reg Bean< /managed-bean-name >

< managed-bean -class>com. Durga soft. Registration Bean

< managed-bean -scope>session

< managed-bean>

< navigation-rule>

< from-view-id>/registration form.jsp</      >

< navigation-case>

< from-outcome>success</from-outcome>




<from-outcome>failure<  >

<to-view-> failure.jsp<  >




<from-view-id >/menu.jsp< >


<from-outcome >registration form</from-outcome>

<to-view-> registration form.jsp</   >






<supported-locale>it</    >

<sup      >te</          >




<var <msg</var>>






Same as prev. applications.