Have an interesting issue.. We have a wordpress XML / RSS service behind our firewall that is localized to multiple countries and works perfectly with chinese, russian, etc.
To expose this service publically we created a simple JSP service that for some reason won't render the foreign characters.
Any ideas would be greatly appreciated.
<%@ page language="java" contentType="application/xml; charset=utf-8" pageEncoding="utf-8"%>
<%@ page session="false"%>
<%@ page import='java.io.BufferedReader' %>
<%@ page import='java.io.InputStreamReader' %>
<%@ page import='java.io.IOException' %>
<%@ page import='java.io.PrintWriter' %>
<%@ page import='java.net.URL' %>
<%@ page import='java.net.URLConnection' %>
<%
//final String URL_BASE = "http://localhost:8080/index.php/";
final String URL_BASE = "http://INTERNALSERVERIP:8888/index.php/";
final String NL = System.getProperty("line.separator");
BufferedReader br = null;
try
{
String feedName = request.getParameter("name");
// if no feed was specified
if (feedName == null || feedName.trim().length() == 0)
{
feedName = "feed1";
}
// set the URL based off the feed name
String urlStr = URL_BASE + feedName.trim().toLowerCase();
System.out.println("urlStr: " + urlStr);
URL url = new URL(urlStr);
URLConnection urlCon = url.openConnection();
br = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
String resLine = null;
while ((resLine = br.readLine()) != null)
{
resLine= new String(resLine.getBytes("ISO8859_1"), "UTF8");
out.println(resLine);
}
}
catch (Throwable t)
{
t.printStackTrace(new PrintWriter(out));
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException ioe)
{}
}
}
%>