@viswasknit • 12 Aug, 2009
hiiiiiiii

any one tell me, how can i develop a multilingual web application with JSP/SERVLET.Please answer me as soon as possible.......😁

viswas kumar
email id <removed>
@sookie • 30 Aug, 2009 Hi viswasknit,

If you use JSTL(JavaServer Pages Standard Tag Library), then in JSP page you can do do using <fmt> tag.You just need to include the jar. For more detailed information check this - Multilingual Web applications in JSP

Any other queries, feel free to ask more 😀

Thanks !
@viswasknit • 01 Sep, 2009 hii sookie

I have already read the link given by you.......but I could not understand ..

please tell me detail about multilingual web application in jsp...........
@Kaustubh Katdare • 01 Sep, 2009
viswasknit
hii sookie

I have already read the link given by you.......but I could not understand ..

please tell me detail about multilingual web application in jsp...........
Maybe it's a better idea to spend some time on the link provided by Sookie and then posting questions about the parts you couldn't understand.
@viswasknit • 01 Sep, 2009 thank you The_Big_K
@sookie • 02 Sep, 2009
viswasknit
hii sookie

I have already read the link given by you.......but I could not understand ..

please tell me detail about multilingual web application in jsp...........
No worries man. Always better to ask questions. May be I gave a very tough link to you 😉. I wanted to tell you following thing in my first post over here only but earlier my machine doesn't have environment required for doing so. Now I made my machine ready for it.

Pre requisite: Assuming you are familiar with creating and running a simple JSP Page in a Web Container [Apache Tomcat right now]

I am using NETBEANS 6.0 IDE
STEP #1: Create a Web Application named "MultiLingualWebApplication" in it.[Optional: Set context path as "mlweb"].
[​IMG]

[​IMG]
STEP # 2: Click "Finish". Default project structure would look like following
[​IMG]

STEP #3: An "index.jsp" page is default created with "Hello World" as display in <BODY> tags. Default page looks like this
[​IMG]

STEP #4:
Now our purpose is to make this "Hello World" display[rather any other thing displaying at user end in UI] in such a way that I need to make minimal number of changes and my application can be called as multilingual.[Showing same application code in different languages.] So for this , we need to create a MessageProperties.properties file [Any name can be given to properties file - just should have extension .properties]. Now what does this MessageProperties file contains. It contains [Key,Value] pair where 'key' is used in jsp pages using <fmt:message> tag and value is the actual value to be displayed."Value" is taken for "Key" during run time.

So now let's us create MessageProperties.properties file. This file should be created in "Source Packages" folder of our web application so that our final WAR file contains this properties file in its "classes" folder. Right click that folder and click on "Properties file"
[​IMG]

Name it as "MessageProperties" and click on "Finish" button
[​IMG]

STEP # 5: Now let us put up contents in this MessageProperties.properties file.As we are making just a basic application so we are putting [Key,Value] pair for displaying "Hello World" in English(US) right now. OK. So here goes our entry in MessageProperties.properties file and it looks like following
[​IMG]

STEP # 6: Now we are supposed to use <fmt> tag in our index.jsp [default] page.For this we need to add JSTL jar. So go to "Libraries" folder shown in our current project structure. Right click on it .
[​IMG]

Select "JSTL1.0" Option and click on "Add Library" in the dialog opened.
[​IMG]
Check if "JSTL1.1 -standard.jar" and " JSTL1.1 -jstl.jar" appearing in "Libraries" folder of our project or not.

STEP # 7: Now add following line in the "index.jsp" page
<%@ taglib prefix="fmt" uri="https://java.sun.com/jsp/jstl/fmt" %>
STEP # 8: Also add following two lines also in your "index.jsp"page
<fmt:setLocale value="en_US"/>
<fmt:setBundle basename="MessageProperties"/>
in <fmt:setLocale>: set "value" of your locale like "en_US" for English(US) or "fr_FR" for French etc..
in <fmt:setBundle>: set "basename" as the name of the properties file[Here, MessageProperties]

STEP # 9: Replace plain "Hello World" text with following tag in index.jsp
<fmt:message key="helloworld"/>
In <fmt:message>: set key same as used in MessageProperties.properties file.

So now our final "index.jsp would look something like below[removing comments]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="https://java.sun.com/jsp/jstl/fmt" %>
<html
<fmt:setLocale value="en_US"/>
<fmt:setBundle basename="MessageProperties"/>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2><fmt:message key="helloworld"/>!</h2>
    </body>
</html>
STEP # 10: Run and deploy the project. In NETBEANS - you can simply right click on "index.jsp" and select "Run File"

[​IMG]

Thanks !

PS: About details about tags refer next to next post.
@viswasknit • 02 Sep, 2009 hii.......
sookie

Thanks very much

I want to develop a project in english and hindi both language........

would i make .properties file to translate all engish word to hindi or any other way .......


plz help me..

I am thankful to you...
@sookie • 02 Sep, 2009 Description about tags used :

The formatting tags are used for internationalization and localization of the jsp pages. Internationalization provides support for various languages and data formats. By localization web applications becomes capable of supporting specific regions or locale.

1). <fmt:message>

This tag is used to output locale sensitive strings. The param subtag along with message provides an argument to the compound message in parent message tag. One param tag must be specified for each variable in the compound message or pattern. Replacement takes place in order of the param tags.

Syntax:
<fmt:message key = "messageKey"
[bundle="resourceBundle"]
[var="varName"]
[scope="{page|request|session|application}"] />

2). <fmt:setLocale>

This tag is used to set the default locale within a specific JSP scope.

<fmt:setLocale value = "en_US" />

3). <fmt:setBundle>

This tag creates an i18n localization context and loads its resource bundle into that context. The name of the resource bundle is specified with the basename attribute.

Syntax:
<fmt:setBundle basename = "basename"
[var="varname"]
[scope="{page|request|session|application}"]/>

[ Source : Rose India ]

In order to make your application "multilingual" you just need to make a separate properties file which contains values in that particular language.

For example -taking previous post example. I can make a separate MessageProperties_fr.properties file which contains "Hello World" in French

MessageProperties_fr.properties file will look like following
helloworld=Bonjour tout le monde
In "index.jsp" we need to change "value" attribute of <fmt:setLocale> to "fr_FR" and in <fmt:setBundle> set "basename" as "MessageProperties_fr".
"index.jsp" would look like this

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="https://java.sun.com/jsp/jstl/fmt" %>
<html>
<fmt:setLocale value="fr_FR"/>
<fmt:setBundle basename="MessageProperties_fr"/>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2><fmt:message key="helloworld"/>!</h2>
    </body>
</html>
Now again run the file, you will get your output["Hello World"] in French as following

[​IMG]


Hope this was of some use. Feel free to ask more questions. 😀
-------------------------------------------------------------------------------------
Addendum
@viswasknit: Sure man, you can do so, I guess my this post can be some help to you. 😀
-------------------------------------------------------------------------------------

Thanks !
@viswasknit • 02 Sep, 2009 @sookie

I am confused that what should i do for translate a english web project in hindi web project ......

would I make to .properties file of all words of english to hindi...


plz give me proper solution ......
@Kaustubh Katdare • 02 Sep, 2009
viswasknit
@sookie

I am confused that what should i do for translate a english web project in hindi web project ......

would I make to .properties file of all words of english to hindi...


plz give me proper solution ......
Dude, how about trying out something on your own?
@Saandeep Sreerambatla • 02 Sep, 2009 Great work sookie 😀


Need to understand something of it. Will post my questions shortly 😀
@viswasknit • 05 Sep, 2009 happy teachers day.........
@Kaustubh Katdare • 05 Sep, 2009
viswasknit
happy teachers day.........
Please avoid off-topic comments.
@prabhakar yadav • 06 Feb, 2017 i want to save my data in excel, when i click on download, my project is in jsp
help me

Related Posts

I thought of compiling a list of the coolest and the best whatsapp group names that you've been using for your respective groups. For the sake of convenience, we'll stick...
A simple good bye email or last working day mail ain't cool! We've some awesome templates that you can use. If you're looking for an amazing Last Working Day email...
Hello CEans, How to convert CGPA (10 Point Scale) to Percentage? Please help!
I heard many students are having a trouble registering on the TCS Portal, when it's quite straightforward actually. If you have problem in attaching photos or CV, Use internet explorer...
What is IES or Indian Engineering Services Exam? Union Public Services Commission (UPSC) conducts the Engineering Services Exam or ESE 2016 is an entrance exam for graduates who wish to...