This is a very simple login demo web-app in struts 1.3 which support Internationalization and Localization (or a multilingual application which in English, Hindi, German, French and Spanish ). So before going any forward I have something share few day before writing this post I attended an interview for Struts 1x I have around 2+ year of experience in struts 1 and then ask me how to handle Internationalization and Localization in struts. And I have never worked with multilingual application before but have some idea about multiple resource file ending with a locale so as I came back got some time wrote and demo for the multilingual app.

You can download source from here

Struts Internationalization Screenshot by

Project Structure

This project structure is maven-archetype-webapp. And depencencies use are listed below.

  • struts-core 1.3.10
  • struts-taglib 1.3.10
  • junit 3.8.1

Project Structure multilingual



	<!-- Struts core lib -->

	<!-- Struts tag lib for jsp -->

We have used 5 properties file for five languages.


dgstack.header.login=Melde dich an, um Anwendungs




dgstack.label.login.reset=rücksetzen Ändern

dgstack.error.username.empty=Benutzername sollte nicht leer
dgstack.error.password.empty=Kennwort sollte nicht leerültiger Benutzername oder Passwort

dgstack.header.success=Anmeldung erfolgreich,


Similar to above properties file. We have all the other properties files.


This jsp is the first thing to appear on the screen here one can login or can language from the bottom. To show all the label as per our selected language we have used bean:message tag to display text from properties file corresponding to there key.

<html:form action="/login" method="post" focus="username">
    		<td colspan="2" style="color:red;">
    			<html:errors />
    			<logic:equal value="true" name="loginError">
    				<bean:message key=""/>
    		<td><bean:message key="dgstack.label.login.username"/></td>
    		<td><html:text property="username"></html:text></td>
    		<td><bean:message key="dgstack.label.login.password"/></td>
    		<td><html:password property="password"></html:password></td>
    		<td><html:submit><bean:message key="dgstack.label.login.submit"/></html:submit></td>
    		<td><html:reset><bean:message key="dgstack.label.login.reset"/></html:reset></td>
    	<h5><bean:message key=""/></h5>
    	<a href=''>English</a> | 
    	<a href=''>&#2361;&#2367;&#2306;&#2342;&#2368;</a> | 
    	<a href=''>Deutsche</a> |
    	<a href=''>Français</a> | 
    	<a href=''>Español</a>  

This Action class is use to change Locale of the current session context. As you can see in the following code we setting a Globals.LOCALE_KEY in session to as per our selected language. Whatever parameter value you set in message-resources in struts-config.xml it will now pick the value and append ‘_’ and your locale, then it will look for that properties file. If that files is not founded it will load default file (means file without locale). In our case if we have selected french it will look for “” file.

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
		HttpServletResponse response) throws Exception {
		request.getSession().setAttribute(Globals.LOCALE_KEY, new  Locale("hi"));//Locale for hindi is not present by default so we to add one for hindi.
	}else if("fr".equals(request.getParameter("to"))){
	}else if("en".equals(request.getParameter("to"))){
	}else if("es".equals(request.getParameter("to"))){
		request.getSession().setAttribute(Globals.LOCALE_KEY,new  Locale("es"));//Locale for spanish is not present by default so we to add one for spanish.
	}else if("de".equals(request.getParameter("to"))){
	return mapping.getInputForward();


This is very simple struts configuration file nothing much in it. we just have on form bean loginform , a LoginAction and ChangeLanguageAction that is used to change the language.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 

		<form-bean name="loginform" type=""></form-bean>
		<action path="/login" name="loginform" validate="true" type="" scope="request" input="/index.jsp">
			<forward name="success" path="/success.jsp" redirect="true"/>
		<action path="/changeLang" type="" scope="request" input="/index.jsp">
	<message-resources parameter="ApplicationResource"></message-resources>

If you have any question can write it down in comment below.

You and find the source on github or you can download it from here. I am sure any one can understand this by just take look at complate source code.

Share :

Subscribe & Social

Subscribe to this blog via RSS.

Recent Posts


Java 14

Python 2

Wordpress 1

Ops 3

Shared 3

Angular 1

Web 1

Draftblog 1

Popular Tags

Java (14) Python (2) Wordpress (1) Ops (3) Angular (1) Web (1) Draftblog (1)


DGStack is web blog by digvijay bhakuni. This blog is about computer programming tips and trick. And some short tutorial and gettings started post about the framework, libriay, api and much more. The blog target mostly open source stuff like java, j2ee, nodeJs, angularJs, spring, struts, mongodb, mean, etc


This website claims no credit for any images posted on this site unless otherwise noted. Images on this blog are copyright to its respectful owners. If there is an image appearing on this blog that belongs to you and do not wish for it appear on this site, please E-mail with a link to said image and it will be promptly removed. And the information is best of my knowledge one can always write comment or mail regarding information is this blog.