HttpServletResponse.setCharacterEncoding - cannot resolve symbol

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Java  script  Dude

    HttpServletResponse.setCharacterEncoding - cannot resolve symbol

    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");

    }
    }
  • Java  script  Dude

    #2
    Re: HttpServletResp onse.setCharact erEncoding - cannot resolve symbol

    I believe this is a bug with NetBeans. setCharacterEnc oding 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.

    Comment

    Working...