"Invalid character constant" with ResourceBundle
843838Nov 9 2006 — edited Nov 9 2006Hi to everybody:
I got a jsp than catch two cookies, one of them to set a Locale variable that I use it to load a ResourceBundle. I deploy it, but when loading the jsp with Tomcat webserver, i got this error.
Here is my code:
<%@page language="java" import="java.util.*" import="java.lang.Object" pageEncoding="Cp1252" contentType="text/html; charset=Cp1252" %>
<%
String cookie1="nomCookie";
String cookie2="idiomaCookie";
Cookie galetes[] = request.getCookies();
Cookie nomCoo = null;
Cookie idiCoo = null;
for (int i=0;i<galetes.length;i++)
{
if(galetes[i].getName().equals(cookie1))
{
nomCoo=galetes[i];
break;
}
}
for (int i=0;i<galetes.length;i++)
{
if(galetes[i].getName().equals(cookie2))
{
idiCoo=galetes[i];
break;
}
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
<title></title>
</head>
<body>
<%
Locale idioma = null;
String p = idiCoo.getValue();
idioma = new Locale(p);
Locale.setDefault(idioma);
ResourceBundle missatges = ResourceBundle.getBundle('idiomes',idioma);
//Enumeration clausBundle = missatges.getKeys();
//String frase1 = missatges.getString("nom");
//String frase2 = missatges.getString("frase");
%>
Nom: <%= nomCoo.getValue() %><br>
Info cookie: <%= idiCoo.getValue() %><br>
Valor p: <%= p %><br>
Valor Idioma: <%= idioma.getDefault() %>
</body>
</html>
and the error is this one:
Ha tenido lugar un error en la l�nea: 39 en el archivo jsp: /6-3.jsp
Error de servlet generado:
Invalid character constant.
What am I doing wrong?? I have found that if I comment line: "ResourceBundle missatges = ResourceBundle.getBundle('idiomes',idioma);", the jsp loads right.
Any idea? thanks to everybody