Reputation: 157
I have a Porblem an I hope that someone could help me.
I'm reading some values from an notes View by using the following Code
...
ViewEntryCollection vec = MyView.getAllEntries();
ViewEntry viewentry = vec.getFirstEntry();
while (viewentry != null) {
row = new Vector<String>();
Vector rowvec = viewentry.getColumnValues();
...
then I build an HTML table with the values this works fine my Problem is the the Response to an Xpage
public void getHTMLStream(DominoFacesContext FacesContext, String HTMLstr) {
ExternalContext con = FacesContext.getExternalContext();
XspHttpServletResponse response = (XspHttpServletResponse)
con.getResponse();
byte[] content;
try {
ServletOutputStream writer = response.getOutputStream();
// setting response headers for browser
response.setContentType("application/html");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Disposition", "attachment; filename=\"myhtml.html\"");
content = HTMLstr.getBytes();
writer.write(content);
writer.flush();
writer.close();
FacesContext.responseComplete();
} catch (Exception e) {
e.printStackTrace();
}
}
If in the HTMLstr are German Umlauts like ä,Ö,Ü the "writer" converts them to some stange signs. Has anyone an idea how to solve this?
Christian
Upvotes: 0
Views: 1788
Reputation: 117
In case anyone still needs this. PrintWriter uses Encoding from xsp properties, so just make sure you have xsp.html.page.encoding=utf-8
Upvotes: 0
Reputation: 2635
Try this:
content = java.net.URLEncoder.encode(content,"UTF-8");
Upvotes: 0
Reputation: 1667
Another options would be to just use the correct method
response.setCharacterEncoding()
Upvotes: 1
Reputation: 131
you can set charset in the contenttype by the following statement
response.setContentType("application/html;charset=UTF-8");
Upvotes: 2