I am investigating a solution to build all pages sent from my
application servlet in UTF-8 encoding. From what I understand, I
should be using HttpServletResp onse.setCharact erEncoding("UTF-8"). The
J2EE API clearly shows that this method is available with superclass
ServletResponse but I am getting compile errors using NetBeans 3.6
final.
Thanks for your help!
Tim
Test Code:
/*************** ***********
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import javax.servlet.* ;
import javax.servlet.h ttp.*;
public class TestCharSet extends HttpServlet{
public void doGet
(HttpServletReq uest request,HttpSer vletResponse response)
throws ServletExceptio n, IOException {
response.setCon tentType("text/html; charset=UTF-8");
/*
This works but don't understand what it would do?
Docs say:
Overrides the name of the character encoding
used in the body of this request.
*/
request.setChar acterEncoding(" utf-8");
/*
This is what I really want to do.
I wish to set the encoding of the responded document
Docs say:
Sets the character encoding (MIME charset) of the response
being sent to the client, for example, to UTF-8.
This one sounds correct but I get the error:
TestCharSet.jav a [15:1] cannot resolve symbol
symbol : method setCharacterEnc oding (java.lang.Stri ng)
location: interface javax.servlet.h ttp.HttpServlet Response
response.setCha racterEncoding( "utf-8");
*/
response.setCha racterEncoding( "utf-8");
}
}
application servlet in UTF-8 encoding. From what I understand, I
should be using HttpServletResp onse.setCharact erEncoding("UTF-8"). The
J2EE API clearly shows that this method is available with superclass
ServletResponse but I am getting compile errors using NetBeans 3.6
final.
Thanks for your help!
Tim
Test Code:
/*************** ***********
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import javax.servlet.* ;
import javax.servlet.h ttp.*;
public class TestCharSet extends HttpServlet{
public void doGet
(HttpServletReq uest request,HttpSer vletResponse response)
throws ServletExceptio n, IOException {
response.setCon tentType("text/html; charset=UTF-8");
/*
This works but don't understand what it would do?
Docs say:
Overrides the name of the character encoding
used in the body of this request.
*/
request.setChar acterEncoding(" utf-8");
/*
This is what I really want to do.
I wish to set the encoding of the responded document
Docs say:
Sets the character encoding (MIME charset) of the response
being sent to the client, for example, to UTF-8.
This one sounds correct but I get the error:
TestCharSet.jav a [15:1] cannot resolve symbol
symbol : method setCharacterEnc oding (java.lang.Stri ng)
location: interface javax.servlet.h ttp.HttpServlet Response
response.setCha racterEncoding( "utf-8");
*/
response.setCha racterEncoding( "utf-8");
}
}
Comment