the code below is not giving me the answer i want, i don't know where is the problem? FR is the translation of EN (exactly like .properties file) i want to read the translation from the FR.java file if i want to reach the hello variable of fr.java or en.java from the index.jsp page. but code i wrote gives me the value from Lang.java
String language = "FR";
the condition is in the .jsp file jdk 1.4 gives me this error :Error(23,23): variable lang might not have been initialized
any body can help, code pleas?
file name Lang.java
package mypackage;
abstract public class Lang {
public String hello= "home page";
}
filename EN.java
package mypackage;
public class EN extends Lang {
public String hello = "hello";
}
filename FR.java
package mypackage;
public class FR extends Lang {
public String hello = "bonjour";
}
file name : index.jsp
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="mypackage.Lang" %>
<%@ page import="mypackage.FR" %>
<%@ page import="mypackage.EN" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>language</title>
</head>
<body>
<%
String language = "EN";
Lang lang;
if (language.equals("EN")){
lang = new EN();
}
else if (language.equals("FR")){
lang = new FR();
}
%>
<%
out.print(lang.hello);
%>
</body>
</html>