Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HttpServletResponse.setCharacterEncoding - cannot resolve symbol

576 views
Skip to first unread message

Java script Dude

unread,
Jun 5, 2004, 1:19:16 PM6/5/04
to
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 HttpServletResponse.setCharacterEncoding("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.http.*;

public class TestCharSet extends HttpServlet{
public void doGet
(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("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.setCharacterEncoding("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.java [15:1] cannot resolve symbol
symbol : method setCharacterEncoding (java.lang.String)
location: interface javax.servlet.http.HttpServletResponse
response.setCharacterEncoding("utf-8");
*/
response.setCharacterEncoding("utf-8");

}
}

Java script Dude

unread,
Jun 6, 2004, 12:05:23 AM6/6/04
to
I believe this is a bug with NetBeans. setCharacterEncoding is only
available in servlet 2.4 and I think that for some reason, NetBeans is
looking at two different servlet*.jar files. This would explain why NB
shows the method on the object but does not compile.

I believe I need to find a different solution.

0 new messages