Problem setting Unicode (utf-8) in http header using tomcat

Hi:
I am trying to set a file name in utf-8 to http header using the following code:
response.setContentType("text/html; charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename=解決.zip");
// I actually has file name in utf-8 here to set to the header, and I know that the name is correctly
// and I also looked into the response object MimeHeaders object and saw the head is correctly there
then write the content of zip file using ServletOutputStream.
The problem I have is that the file name is not displayed correctly when prompted to save or open in the pop up window next. I found out using Fiddler that the request header is wrong:
Content-disposition: attachment; filename=�zn��.zip
I am using Tomcat 5.0.28. Any idea how to get this working?
Thanks in advance!

You are setting the charset for the content to be UTF-8. (That is why the method is called setContentType.) But HTTP headers are not part of the content and so that has no effect on the header.
The original specification for HTTP only allowed US-ASCII characters in headers. It is possible that more recent versions have features that allow for non-ASCII header data, but I don't know if that is the case or how you would use those features if they exist.

Similar Messages

  • Which OAM setting for passing values in HTTP header to application

    Experts, what is the setting in OAM 11gR2 that is set to pass a userid pulled from a LDAP directory (which is already configured with OAM) as a HTTP Header to an application.
    This is typically in cases where OAM is protecting or providing to protected resources on a Web Server or application.
    Is this setting (in OAM) by default set to userid? I wanted to know exactly where and how to set this value in OAM Console settings.

    In the protected resource policy and protected authorization policy in the responses tab set parameters to return headers for example if you want to return userid under name set header name like user_name, type header and the value as $user.userid. By default I guess OAM_REMOTE_USER is set in the http headers which contains the user id.

  • How can I set "SOAPAction" http header using SAAJ

    When I send soap request, http header's like below
    SOAPAction: ""
    But, I'd like to send like this
    SOAPAction: "http://tempuri.org/HelloWorld"
    How can I that using SAAJ ?
    My code is
    String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
    "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
    " <soap:Body>\n" +
    " <HelloWorld xmlns=\"http://tempuri.org/\" />\n" +
    " </soap:Body>\n" +
    "</soap:Envelope>";
    Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes()));
    DOMSource domSource = new DOMSource(doc);
    SOAPMessage message = MessageFactory.newInstance().createMessage();
    message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "utf-8");
    message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
    message.getSOAPPart().setContent(domSource);
    message.writeTo(System.out);
    SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = connection.call(message, helloURL);
    connection.close();
    SOAPBody body = response.getSOAPBody();
    if ( body.hasFault() )
    SOAPFault newFault = body.getFault();
    System.out.println("SoapBody has fault.");
    System.out.println("code=" + newFault.getFaultCodeAsName());
    System.out.println("message=" + newFault.getFaultString());
    System.out.println("actor=" + newFault.getFaultActor());
    else
    System.out.println("Call Successed.");
    System.out.println(body);
    }

    message.getMimeHeaders().addHeader("SOAPAction", "http://tempuri.org/HelloWorld");

  • Problem setting up database for dreamweaver 8 to use on testing server

    I am trying to try out dreamweavers database features, by
    trying to set up a connection to mysql database. How ever I recieve
    errors when trying to select my database. Either I get a long error
    that says it can not find localhost//_mmHTTP... something like that
    or undefiend errors message.
    I am using wamp5 set up on my local machine that installed
    apachie,php,mysql in one package. So maybe that has something to do
    with it, but none the less can someone give me a example of how
    they set theirs up to work with examples of where files should be
    located I can not seem to find anything like this in google, and I
    dont want to set it up on a remote server yet until I tested things
    on my local machine.

    Thanks Seth,
    I ran jcounsole, but I don't see anything except the process monitor registered.
    I don't think the server is starting sucessfully after the exception becuase I don't see the other parts
    of the application running.
    I forgot to mention in the last post that I've also added the line
    <BR>
    <BR>
    -Xbootclasspath/a:C:\bea\wlevs20\bin\mysql-connector-java-3.0.17-ga-bin.jar
    <BR>
    to the startup script to add in the location of the jar file that contains the JDBC driver.
    I was going to post the full stacktrace, but it's fairly long so I'll hold off unless you think it may help.
    I do get one additional exception after the <Server STARTED> message which is:
    A service of type "com.bea.core.datasource.DataSource:com.bea.core.datasource.DataSourceFactory" from file "OSGI-INF/datasource.xml" in bundle "com.bea.core.datasource" could not be advertised because all required services are not available. In particular, these are not available:
         1. RequiredReferenceImpl(filter="(objectClass=com.bea.core.transaction.TransactionManagerService)")
    <BR>
    but I think it may be related to the fact that the data source isn't being created.
    <BR>
    Thanks very much for taking a look,
    <BR>
    Mike

  • I am having problems setting the gain programatically from Labview 6, using the Hardware Config vi, for a PCI6110E DAQ board.

    NB: This has also been posted to High Speed Digitizers forum.
    Changing the "gain" (part of the "alternate input limits" cluster) appears to affect the group settings, but when I pass a signal outside the supposed new voltage range, the signal doesn't clip as I would expect. This doesn't happen when I use MAX (where clipping is clearly visible), but unfortunately that is not an acceptable long-term solution. Any thoughts? I am only using allowable gain settings for the 6110E.
    Additionally, I am saving my data in hsdl format, and to get the actual true voltage from the binary numbers (after uncompressing and converting back to standard binar
    y format) I need to multiply the final number by the gain. Should this be correct? I thought the "scale multiplier" (part of "group settings cluster") compensated for "gain", but it doesn't seem to do so. Is this part of the same problem?

    Thanks Spencer. I do call Hardware Config.vi in several different places, so maybe its the multiple calls that is stuffing things up. I will investigate further.
    As for the multiplier, which bit sounds correct? The fact that I have to multiply by the gain, or that it should take this into account automatically and therefore not have to muliply by the gain (which is what the default hsdl code does). What do you do to convert from binary to real?
    Thanks for your help,
    Jo

  • Problems with JSP and Tag Libraries in JBoss using Tomcat 5.5.9

    Hi,
    I am experiencing a really weird situation here. When running a deployed EJB3 ear application in a JBoss 4.0.3sp1 application using Tomcat service 5.5.9, Jasper is unable to compile any JSP file using Tag Libraries. To be more precise, when generating the Java source file (looking in the 'work' directory) everything in the file after the first occurance of a Tag Library usage is commented out (with "//"), causing the Java source to be invalid and outputs an error when accessing the page via a browser saying:
    "org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Syntax error, insert "}" to complete ClassBody
    Generated servlet error:
    Syntax error, insert "}" to complete Block
    Generated servlet error:
    Syntax error, insert "finally" to complete TryStatement
    Generated servlet error:
    Syntax error, insert "}" to complete MethodBody"
    etc... where every error row is a suggestion of steps to take to make the source file valid. (of course).
    The Tag Library jar files are located in the web application WEB-INF/lib folder as they should be. The descriptive Tag Library Definition files (tld:s) are located in the WEB-INF folder and every JSP file references these tld files directly via this path (WEB-INF/).
    Any hints are most appreciated!!
    Cheers!
    /Henrik

    Hi,
    I am experiencing a really weird situation here. When running a deployed EJB3 ear application in a JBoss 4.0.3sp1 application using Tomcat service 5.5.9, Jasper is unable to compile any JSP file using Tag Libraries. To be more precise, when generating the Java source file (looking in the 'work' directory) everything in the file after the first occurance of a Tag Library usage is commented out (with "//"), causing the Java source to be invalid and outputs an error when accessing the page via a browser saying:
    "org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Syntax error, insert "}" to complete ClassBody
    Generated servlet error:
    Syntax error, insert "}" to complete Block
    Generated servlet error:
    Syntax error, insert "finally" to complete TryStatement
    Generated servlet error:
    Syntax error, insert "}" to complete MethodBody"
    etc... where every error row is a suggestion of steps to take to make the source file valid. (of course).
    The Tag Library jar files are located in the web application WEB-INF/lib folder as they should be. The descriptive Tag Library Definition files (tld:s) are located in the WEB-INF folder and every JSP file references these tld files directly via this path (WEB-INF/).
    Any hints are most appreciated!!
    Cheers!
    /Henrik

  • ESB requires "SOAPAction" to be set in HTTP header?

    I'm trying to insert an ESB flow between an existing web service and client. The service and client were previously built with Apache Axis.
    By generating an appropriate WSDL (doc/wrapped rather than Axis' default RPC style) for the existing service, I'm able to connect the ESB to the service.
    The problem is that the existing client (built using Axis) sets the SOAPAction in the HTTP header to empty (SOAPAction: ""), and the ESB appears to require this to be set to the desired operation. If this is a hard requirement, then I can't directly connect the existing client to the ESB flow.
    So, the question is whether it's possible to have the ESB relax the requirement for the SOAPAction header. And if so, how?
    If I can't get the ESB to accept SOAP requests with an empty SOAPAction, then I'll have to create a custom adapter or insert an additional proxy layer (yuk). Anyone else have any suggestions?

    This is all done automatically by FB.
    Just to try something out I just now made a simple app with a label only and tried to upload to Google... FAILED!!!!
    "Market requires versionCode to be set to a positive 32-bit integer in AndroidManifest.xml"
    LOL, FB can't even create this. :-/
    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <application xmlns="http://ns.adobe.com/air/application/3.1">
    <!-- Adobe AIR Application Descriptor File Template.
              Specifies parameters for identifying, installing, and launching AIR applications.
              xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/3.1
                                  The last segment of the namespace specifies the version
                                  of the AIR runtime required for this application to run.
              minimumPatchLevel - The minimum patch level of the AIR runtime required to run
                                  the application. Optional.
    -->
    Message was edited by: KesherMedia.Com

  • How to Set UserId in Http Header for SSO?

    Hello All,
    I have a requirement to set the userid into the HTTP Header so that i can use the "Header Variables for User Authentication" module provided by SAP to achieve the SSO .
    Could some 1 let me know how can I achieve this? I know abt the HTTPServlet.setheader() method, But i need to set it using my JAVA application. Is there any way to set the HTTP Header using Java. I have already done a lot of googling, but havent got any results.
    I am sure that, there must definitely be a way in which we can add the user id into the HTTP header, in all the results, they tell abt adding it using the HTTP Servlet or PHP and so on, but i need to add it from JAVA.(setting REMOTE_USER as "mysapuserid")
    I have already added the "HeaderVariableLoginModule" in my login stack in the 2nd position, as per
    http://help.sap.com/saphelp_nw04/helpdata/en/8f/ae29411ab3db2be10000000a1550b0/frameset.htm
    Any pointers will be helpful,
    Meghana
    Edited by: Meghana Phadke on Apr 14, 2008 2:49 PM

    Hi
    As I understand, your java application is an EP client, check framework HttpClient :
    http://hc.apache.org/httpclient-3.x/
    http://hc.apache.org/httpclient-3.x/tutorial.html
    Hope this help
    Jakub Krecicki

  • How to deal with the "Set-Cookie" field in HTTP header??

    I follow the RFC-2616 specification to write a socket program to fetch web pages.
    I have to deal with all the fields included in the HTTP header.
    But the RFC-2616 doesn't talk anything about the "Set-Cookie" field.
    Does anyone know how to handle this field or provide me any useful documentation.
    Any help is appreciated.

    A cookie is set with the "Set-Cookie: "-field in the http header, like this:
    Set-Cookie: mycookie=someValue
    This cookie should only be returned to the same host as it came from, like this in the http header of a request:
    Cookie: mycookie=someValue
    If the parameter looks like this:
    Set-Cookie: mycookie=someValue; path=/cgi-bin
    , the cookie should only be returned to the host if the request path starts with /cgi-bin
    If the parameter looks liek this:
    Set-Cookie: mycookie=someValue; domain=.mydomain.com
    , the cooke should be returned to all hosts in the .mydomain.com-domain
    There is also a "expires="-field, which works as expected and a "secure"-field, which I'm not sure how to handle. Maybe the cookie should only be sent to an SSL-enabled host?
    Hope this helps you. Bye,
    Dag W.

  • How to set custom HTTP header for single sign on

    Currently we just begin to use an application called "etran". This application requires user name and password to login. Now, my assignment is to integrate etran application in our internal application. This means that somewhere in our internal application, there is a link leads to the etran application.
    It is going to be single sign on, that means that once user logs into our internal application, when he/she clicks on the etran link, no sign on to etran is needed.
    I consult with the technical people in etran. they said that our internal application needs to send a "login request" to etran via SSL with the user's information encoded in base 64 format. etran captures the HTTP header containing user authentication and authorization information, and parses the required information from the HTTP header.
    My question is that how I set user information in HTTP header? From my understanding, once I am able to set the user information in HTTP header, it is in base 64 format?
    Thanks in advance for your help.

    sharon38_74 wrote:
    they said that our internal application needs to send a "login request" to etran via SSL with the user's information encoded in base 64 format. etran captures the HTTP header containing user authentication and authorization information, and parses the required information from the HTTP header.
    My question is that how I set user information in HTTP header? From my understanding, once I am able to set the user information in HTTP header, it is in base 64 format?Your application need to act like a proxy. You can invoke a HTTP request programmatically using java.net.URLConnection. You can set request headers using URLConnection#setRequestProperty(). Also see the API docs: [http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html]. You only need to know the header field name where to set the Base64-encoded value in. You need to Base64-encode the value yourself.

  • ColdFusion won't display unicode (utf-8) characters

    I have a very basic page with some unicode characters in it. ColdFusion won't properly display them. If I resave the page as .html (so the coldfusion server doesn't process it), the characters display fine.
    Below is my page. Notice that the charset is set to utf-8.
    I'm using Dreamweaver CS5.5. Running IIS 7 and CF 9.
    The text "why isn’t this working" has a smart apostrophe that DOES NOT DISPLAY PROPERLY when run through CF. I've searched around and all I see is that CF has unicode "turned on by default" but no where can I find where to make sure it is set.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    </head>
    <body>
    why isn’t this working?
    </body>
    </html>

    it seems that having cfprocessingdirective in every template is a documented best-practice in the CFWACK (Vol 2).  I learned something new today. 
    God, really?  Who came up with that?
    One needs to put it in any file that has characters with "ASCII" codes higher than 127, so as to forewarn the compiler to expect them.  I also dunno why one can't just tell the compiler "treat all files this way".  It's daft not to.
    Anyway, most CFM files - which ought to contain just code - shouldn't have a problem because code won't generally have anything outside the 0-127 range; just the odd hard-coded value.  So to recommend to put it at the top of every file is just stupid.  Put it in the files that need it. That's it.
    As to why it needs to go in the file itself rather than somewhere "upstream" in the request - like OnRequestStart() or something is that this tag - unlike most - is a compile time directive (as opposed to runtime).  And at compile time, CF is not running the code, it's just compiling it, so it doesn't know anything about the sequence in which files will be called (indeed it's not actually the CFM files themselves being called anyhow).
    Adam

  • Setting webservice response content type / charset header

    I have a webservice .war file.
    I need to set the content-type/charset http header and add another http header. I wrote a filter to do that and had partial success. The other header (pics-label) is indeed sent in the response with the correct value. However, setting the content type proved to be another matter.
    I read through the documentation that one can set the system property weblogic.webservice.i18n.charset=utf-8. However, this doesn't seem to work. The filter setting the header also doesn't work. It seems that weblogic has the final word on that. Only when I set the <web-service> element attribute charset="UTF-8" does the header gets back to the client.
    Due to deployment/build related issues which I won't get into, this is most annoying.
    If anyone has encountered a similiar issue and have a solution/workaround/thoughts I'll be glad to hear about it.
    P.S.
    Also tried -Dfile.encoding=UTF-8 but didn't do any good.
    Thanks.

    you don't define a charset for non-text file types. Excel files are not text files.

  • HTTP header in HTTP reponse

    i have a HTTP request--->BPM--->Http Response, there is a S/A bridge to implement this
    for which i there is a
    1. HTTP sender channel (outbound synchronous message interface),
    2. BPM,
    the requirement is...in the sync HTTP response, i need the HTTP header "content-length"to be changed to 0,
    for this i wanted to use the "Set adapter specific message attribute -> HTTP header fields (Synchronous response)" in the HTTP sender channel,
    but i cant see this field in the sxi_monitor in the Dynamic configuration tab of the Response Message...
    pls help me solving this

    Try this
    [http://help.sap.com/saphelp_nw04/helpdata/en/43/64dbb0af9f30b4e10000000a11466f/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/43/64dbb0af9f30b4e10000000a11466f/content.htm]
    Also the Stream Transformation Constants which we can access using Dynamic Configuration:
    [http://help.sap.com/javadocs/NW04S/current/pi/com/sap/aii/mapping/api/StreamTransformationConstants.html|http://help.sap.com/javadocs/NW04S/current/pi/com/sap/aii/mapping/api/StreamTransformationConstants.html]
    Edited by: Praveen Gujjeti on Apr 21, 2009 12:24 PM

  • REG : HTTP header fields (Synchronous response)

    Hi All,
             Can anyone please explain the advantage of using this function in the receiver HTTP adapter( ie
    "Set adapter specific message attribute -> HTTP header fields (Synchronous response)")
    and how this can be implemented?
    Thanks in Adavnce,
    Siva

    >
    sivarama krishna wrote:
    > Hi All,
    >
    >          Can anyone please explain the advantage of using this function in the receiver HTTP adapter( ie
    > "Set adapter specific message attribute -> HTTP header fields (Synchronous response)")
    >  and how this can be implemented?
    >
    >
    >
    > Thanks in Adavnce,
    > Siva
    from help:
    If you want to save HTTP header fields from the synchronous response in the XI message header, choose HTTP Header Fields (Synchronous Response) and enter the fields in the fields Field 1 to Field 6.
    The fields must have the same names as the fields that are also to be sent in the HTTP response.
    The technical names of the fields are HeaderFieldOne,...,HeaderFieldSix.
    this means that in case you look to access the header of the response message of a sync http you can use this ASMA.
    the implementation will be in your response mapping, using dynamic configuration - /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

  • About http header

    hello everybody!
    i got a problem that how to catch the http header!
    i can get some of header info as bellow
    URL url1 = new URL(httpString);
    HttpURLConnection urlc = (HttpURLConnection)url1.openConnection();
    for (int i = 0; i < urlc.getHeaderFields().size(); i++) {
    System.out.println(urlc.getHeaderFieldKey(i) + ":"+urlc.getHeaderField(i));
    but, i can't catch the "Location:" part
    i can see that the site had reply me with
    "Moved Temporarily"
    "Location:http://redir-url/"
    under the help of "sniffer software" and that Location part of the header is just what i want to catch.
    could anybody can tell me how can i catch this Location part of a http header through java program?

    If you wish you code robust you should cosinder 301: Moved Permanently too:
    * HTTP Status-Code 301: Moved Permanently.
    public static final int HTTP_MOVED_PERM = 301;
    * HTTP Status-Code 302: Temporary Redirect.
    public static final int HTTP_MOVED_TEMP = 302;
    Paste a key code piece just for demo:
    if(getFollowRedirects()
    && (getResponseCode()== HTTP_MOVED_PERM || getResponseCode()==HTTP_MOVED_TEMP)
    && redirectionCounter<=5 //Avoid infinite redirection loops
    String location=getHeaderField("Location");
    URL movedURL=new URL(url,location);
    HttpURLConnection connection=new HttpURLConnection(movedURL,mailbox,proxyInetAddress,proxyPort);
    connection.connect(redirectionCounter+1);
    clientSocket=connection.clientSocket;
    url=movedURL;
    You can see the full source code of HttpURLConnection.java at http://www.mokabyte.it/2000/06/firewallutil.htm .

Maybe you are looking for