aspose file tools*
The moose likes Struts and the fly likes Internationalization login thru to... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Internationalization login thru to..." Watch "Internationalization login thru to..." New topic
Author

Internationalization login thru to...

Alex Kovalchuk
Greenhorn

Joined: Oct 20, 2004
Posts: 13
I am creating a test to allow you to sign in and get a welcome page (jsp) that will ask if you with to Navigate (via a link) in English or Spanish (kinda like an ATM). Then it will go to the login form page (jsp) for (drop down) name and password. And it should go to the main menu (jsp) page. That is where it is not going. It goes back to the welcome page.

Here are the jsps;
---------
Welcome page (index.jsp) (trying to drag out the LOCALE I am getting a null value)
---------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ 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">
<% String locale = (String)session.getAttribute("org.apache.struts.action.Action.LOCALE_KEY, local"); %>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE><bean:message key="index.title"/></TITLE>
<html:base/>
</HEAD>
<body bgcolor="#FCFBCD">
<h3><bean:message key="index.heading"/></h3>
<ul>
<li>
<html:link page="/AppSO.jsp?language=english">
<bean:message key="index.logon.english"/>
</html:link>
<li>
<html:link page="/AppSO.jsp?language=spanish">
<bean:message key="index.logon.spanish"/>
</html:link>
</li>
</ul>
<p> </p>
</body>
</html:html>
-----------
login jsp (AppSO.jsp)
-----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<% if( request.getParameter("language") == null )
{
request.getRequestDispatcher("index.jsp").forward(request, response);
}

// language == "english" or language == "spanish" - so set the locale....
// do the same thing as the setLocale() method in the Action class
// LOCALE_KEY
String language = request.getParameter("language");
java.util.Locale locale = null;

if (language.equals("english"))
{
locale = java.util.Locale.ENGLISH;
}
else if (language.equals("spanish"))
{
locale = new java.util.Locale("es","ES");
}

session.setAttribute(org.apache.struts.action.Action.LOCALE_KEY, locale);
%>
<head>
<!--
This is JAVA code that gets the individual data elements
from the UI Bean that are to be used by this page to
access all dynamic data. -->
<TITLE><bean:message key="logon.title"/></TITLE>
<script language="JavaScript" type="text/JavaScript">
function validate(form)
{
dataIsOK = true
if (form.j_username == null || form.j_username.value == null || form.j_username.value == "1")
{
window.alert("Please select an Area Office/Seleccione por favor una oficina del �rea")
dataIsOK = false
}

if (form.j_password == null || form.j_password.value == null || form.j_password.value == "")
{
window.alert("You must enter a password/Usted debe incorporar una contrase�a")
dataIsOK = false
}

return dataIsOK
}
</script>
</head>
<BODY bgcolor="#FFFFFF">
<TABLE BORDER="0" align="center" width="750">
<TR>
<TD>
<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time < 10)
{
document.write("<b>Good morning/Buenos d�as</b>")
}
else
{
document.write("<b>Good day/Buonas d�az</b>")
}
</script>
<br>

<%if ( null != request.getParameter("error") )
{%>
<b>*</b>
<%}%>
<%if ( null == request.getParameter("error") )
{%>
<b>Guest/Hu�sped</b>
<%}%>
<%if (request.getParameter("error") != null) {%>
<CENTER><B><FONT COLOR="RED">
<bean:message key="prompt.errorname"/>
</FONT></B></CENTER>
<%}%>
<h2 align="center">
<font face="Arial, Helvetica, sans-serif">
<bean:message key="prompt.regionlogin"/>
</font></h2>
<p align="center"><b> </b>
<b> </b><font color=#8B008B><big>
***
<bean:message key="prompt.signonmessage"/>
***
</big> </font><br>
<font face="Arial, Helvetica, sans-serif"><br>
<br>
</font>

<form action="j_security_check" method="POST" onSubmit="return validate(this)">

<table width="100%" border="2" cellpadding="3" cellspacing="0" bordercolor="#284E9B">
<tr>
<td><br>
<table width="74%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" width="5%">
<font face="Arial, Helvetica, sans-serif"> </font>
</td>
<td width="32%" valign="top">
<font face="Arial, Helvetica, sans-serif">
<bean:message key="prompt.region"/>
</font></td>
<td width="63%">
<p>
<SELECT NAME="j_username" SIZE="1">
<OPTION VALUE="0"><bean:message key="prompt.selectone"/>
<OPTION VALUE="TEST1"><bean:message key="prompt.north"/>
<OPTION VALUE="TEST2"><bean:message key="prompt.south"/>
<OPTION VALUE="TEST3"><bean:message key="prompt.northeast"/>
<OPTION VALUE="TEST4"><bean:message key="prompt.southcentral"/>
<OPTION VALUE="TEST5"><bean:message key="prompt.southeast"/>
<OPTION VALUE="TEST6"><bean:message key="prompt.west"/>
<OPTION VALUE="TEST7"><bean:message key="prompt.east"/>
</SELECT> <br>
</td>
</tr>
<tr>
<td valign="top" width="5%">
<font face="Arial, Helvetica, sans-serif"> </font>
</td>
<td width="32%" valign="top">
<font face="Arial, Helvetica, sans-serif">
<bean:message key="prompt.password"/>
</font></td>
<td width="63%">
<font face="Arial, Helvetica, sans-serif">
<INPUT TYPE=password NAME="j_password" SIZE=10 MAXLENGTH=10 VALUE="">

</font></td>
</tr>
<tr>
<td valign="top" width="5%"> </td>
<td width="32%"> </td>
<td width="63%"> </td>
</tr>
<tr>
<td valign="top" width="5%">
<font face="Arial, Helvetica, sans-serif">
</font></td>
<td width="32%">
<font face="Arial, Helvetica, sans-serif">
</font>
<!--
<table border="0">
<tr>
<th></th>
<th><font face="Arial, Helvetica, sans-serif"></font></th>
</tr>
<tr>
<td>
<font face="Arial, Helvetica, sans-serif">
<input type=RADIO name="CURRENT_APPS_INDEX" value="1" CHECKED>
</font></td>
<td align="left">
<font face="Arial, Helvetica, sans-serif">
<bean:message key="prompt.currentapplications"/>
</font></td>
</tr>
<tr>
<td>
<font face="Arial, Helvetica, sans-serif">
<input type=RADIO name="CURRENT_APPS_INDEX" value="2">
</font></td>
<td align="left">
<font face="Arial, Helvetica, sans-serif">
<bean:message key="prompt.allapplications"/>
</font></td>
</tr>
</table> -->
<font face="Arial, Helvetica, sans-serif">
</font></td>
<td width="63%"> </td>
</tr>
<tr>
<td valign="top" width="5%">
<font face="Arial, Helvetica, sans-serif">
</font></td>
<td width="32%">
<font face="Arial, Helvetica, sans-serif">
</font></td>
<td width="63%"> </td>
</tr>
<tr>
<td valign="top" colspan="3">
<div align="center">
<input type=SUBMIT name="LOGIN_BUTTON" value=<bean:messagekey="logon.login"/> class="buttonstyle">
</div>
</td>
</tr></table>
<br>
</td>
</tr>
</table>
<br>

</form>
</TD>
</TR>
</TABLE>
</BODY>
</html:html>
------------------------
Need more info??
Thanks in advance,
Alex
Alex Kovalchuk
Greenhorn

Joined: Oct 20, 2004
Posts: 13
P.S. I was trying to look in the welcome page to see if I already assigned a language to it... if I did then I could redirect it to the main menu page. But... as I said... I am getting nulls back from the Locale.

Thanks again,
Alex
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalization login thru to...