multilingual web application development with JSP/SERVLET

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

Replies

  • sookie
    sookie
    Hi viswasknit,

    If you use JSTL(JavaServer Pages Standard Tag Library), then in JSP page you can do do using tag.You just need to include the jar. For more detailed information check this - #-Link-Snipped-#

    Any other queries, feel free to ask more 😀

    Thanks !
  • viswasknit
    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...........
  • Kaustubh Katdare
    Kaustubh Katdare
    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
    viswasknit
    thank you The_Big_K
  • sookie
    sookie
    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 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 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 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

    in : set "value" of your locale like "en_US" for English(US) or "fr_FR" for French etc..
    in : set "basename" as the name of the properties file[Here, MessageProperties]

    STEP # 9: Replace plain "Hello World" text with following tag in index.jsp
    In : 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" %>
    
    
        
            
            JSP Page
        
        
            

    !

    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
    viswasknit
    hii.......
    #-Link-Snipped-#

    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
    sookie
    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).

    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:
    [bundle="resourceBundle"]
    [var="varName"]
    [scope="{page|request|session|application}"] />

    2).

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



    3).

    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:
    [var="varname"]
    [scope="{page|request|session|application}"]/>

    [ Source : Overview of JSTL Tags ]

    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 to "fr_FR" and in 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" %>
    
    
    
        
            
            JSP Page
        
        
            

    !

    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
    viswasknit
    @#-Link-Snipped-#

    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
    Kaustubh Katdare
    viswasknit
    @#-Link-Snipped-#

    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
    Saandeep Sreerambatla
    Great work sookie 😀


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

You are reading an archived discussion.

Related Posts

Hello fellow engineers! Name: Jason *Engineering Trade: Aerospace Location: US, West Coast *Occupation: New Grad. Had a nice job lined up straight out of college until they announced massive layoffs...
Can any body suggest me literature about foulig factors for various fludis
HI DEAR FRDS IAM TARUN PERSUING MY ELECTRICAL AND ELECTRONIC ENGG FROM ANAND ENGG. COLLEGE,AGRA I NEED SOME ABOUT THE PROJECTS THAT CAN BE DONE IN THE FINAL YEAR INFACT...
Mystical Ball Will read ur mind Interesting game check it put yourself....... MysticalBall.com - The Magical Crystal Ball
hello i'm working on spectrum sensing techniques in cognitive radio...it is an emerging topic and we don't find any codes or any help for it. i'm also facing problems as...