Unforce HTTP headers in WL Servlets

Is there a way to force the Servlet to not set the "Content-type" header, or any
          header for that matter? I am having problems printing cookies and setting a
          location. Whenver I use setHeader or sendRedirect, I no longer can send
          cookies.I tried using the ServletOutputStream and print "Location:..." and
          "Set-Cookie:..." for each one of my cookies, but "Content-type" is set
          automatically and I get my header settings displayed verbatim.
          Has anyone ever ran into this problem? Is there a workaround? Any help would be
          appreciated.
          Justin Knowlden <[email protected]>
          Software Developer
          MyPoints.com, Inc.
          

No, I just had some problems with cookies that were only solved by
          introducing the handling I described below and thought it might be helpful
          for you to try something similar.
          Cameron Purdy
          [email protected]
          http://www.tangosol.com
          Consulting Services Available
          "Justin Knowlden" <[email protected]> wrote in message
          news:[email protected]...
          > Does that mean you actually sent cookies and printed Location in the same
          > request?
          >
          > Cameron Purdy wrote:
          > >
          > > I was not pleased in general with WL's cookie handling. It was very
          frail
          > > to say the least. (This stands in contrast with my overall opinion of a
          > > well-built product.) I would test addCookie before vs. after the
          > > sendRedirect to see if that makes a difference. I don't remember the
          exact
          > > weirdnesses, but I ended up having the addCookie call only on the front
          > > servlet (which all app requests went through), and only if the cookie
          data
          > > changed.
          > >
          > > --
          > >
          > > Cameron Purdy
          > > http://www.tangosol.com
          > >
          > > "Justin Knowlden" <[email protected]> wrote in message
          > > news:[email protected]...
          > > > I have been playing around and HTTpServletResponse does throw back the
          > > "302 -
          > > > Moved Temporarily" status. I then tried to set this status myself with
          > > > setStatus() and then set my cookies but I did not print Location. The
          > > result was
          > > > that 302 was returned as were my cookies. As soon as I set Location in
          the
          > > > header, everything else I did was overwritten.
          > > >
          > > > Basically, if I set Location, I'm screwed. Does anyone know a way
          around
          > > this
          > > > behavior?
          > > >
          > > > Cameron Purdy wrote:
          > > > >
          > > > > The redirect is known ... I think it uses an HTTP error number to
          tell
          > > the
          > > > > browser to redirect, and the cookie doesn't get saved by the client
          > > (maybe
          > > > > even WebLogic does not send it back ... I haven't actually seen what
          > > gets
          > > > > passed at that level.)
          > > > >
          > > > > --
          > > > >
          > > > > Cameron Purdy
          > > > > http://www.tangosol.com
          > > > >
          > > > > "Justin Knowlden" <[email protected]> wrote in message
          > > > > news:[email protected]...
          > > > > > Is there a way to force the Servlet to not set the "Content-type"
          > > header,
          > > > > or any
          > > > > > header for that matter? I am having problems printing cookies and
          > > setting
          > > > > a
          > > > > > location. Whenver I use setHeader or sendRedirect, I no longer can
          > > send
          > > > > > cookies.I tried using the ServletOutputStream and print
          "Location:..."
          > > and
          > > > > > "Set-Cookie:..." for each one of my cookies, but "Content-type" is
          set
          > > > > > automatically and I get my header settings displayed verbatim.
          > > > > >
          > > > > > Has anyone ever ran into this problem? Is there a workaround? Any
          help
          > > > > would be
          > > > > > appreciated.
          > > > > >
          > > > > > --
          > > > > > Justin Knowlden <[email protected]>
          > > > > > Software Developer
          > > > > > MyPoints.com, Inc.
          > > >
          > > > --
          > > > Justin Knowlden <[email protected]>
          > > > Software Developer
          > > > MyPoints.com, Inc.
          >
          > --
          > Justin Knowlden <[email protected]>
          > Software Developer
          > MyPoints.com, Inc.
          

Similar Messages

  • Generate PDF using Managed Bean with custom HTTP headers

    Background
    Generate a report in various formats (e.g., PDF, delimited, Excel, HTML, etc.) using JDeveloper 11g Release 2 (11.1.2.3.0) upon clicking an af:commandButton. See also the StackOverflow version of this question:
    http://stackoverflow.com/q/13654625/59087
    Problem
    HTTP headers are being sent twice: once by the framework and once by a bean.
    Source Code
    The source code includes:
    - Button Action
    - Managed Bean
    - Task Flow
    Button Action
    The button action:
    <af:commandButton text="Report" id="submitReport" action="Execute" />
    Managed Bean
    The Managed Bean is fairly complex. The code to `responseComplete` is getting called, however it does not seem to be called sufficiently early to prevent the application framework from writing the HTTP headers.
    HTTP Response Header Override
    * Sets the HTTP headers required to indicate to the browser that the
    * report is to be downloaded (rather than displayed in the current
    * window).
    protected void setDownloadHeaders() {
    HttpServletResponse response = getServletResponse();
    response.setHeader( "Content-Description", getContentDescription() );
    response.setHeader( "Content-Disposition", "attachment, filename="
    + getFilename() );
    response.setHeader( "Content-Type", getContentType() );
    response.setHeader( "Content-Transfer-Encoding",
    getContentTransferEncoding() );
    Issue Response Complete
    The bean indirectly tells the framework that the response is handled (by the bean):
    getFacesContext().responseComplete();
    Bean Run and Configure
    public void run() {
    try {
    Report report = getReport();
    configure(report.getParameters());
    report.run();
    } catch (Exception e) {
    e.printStackTrace();
    private void configure(Parameters p) {
    p.put(ReportImpl.SYSTEM_REPORT_PROTOCOL, "http");
    p.put(ReportImpl.SYSTEM_REPORT_HOST, "localhost");
    p.put(ReportImpl.SYSTEM_REPORT_PORT, "7002");
    p.put(ReportImpl.SYSTEM_REPORT_PATH, "/reports/rwservlet");
    p.put(Parameters.PARAM_REPORT_FORMAT, "pdf");
    p.put("report_cmdkey", getReportName());
    p.put("report_ORACLE_1", getReportDestinationType());
    p.put("report_ORACLE_2", getReportDestinationFormat());
    Task Flow
    The Task Flow calls Execute, which refers to the bean's `run()` method:
    entry -> main -> Execute -> ReportBeanRun
    Where:
    <method-call id="ReportBeanRun">
    <description>Executes a report</description>
    <display-name>Execute Report</display-name>
    <method>#{reportBean.run}</method>
    <outcome>
    <fixed-outcome>success</fixed-outcome>
    </outcome>
    </method-call>
    The bean is assigned to the `request` scope, with a few managed properties:
    <control-flow-rule id="__3">
    <from-activity-id>main</from-activity-id>
    <control-flow-case id="ExecuteReport">
    <from-outcome>Execute</from-outcome>
    <to-activity-id>ReportBeanRun</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <managed-bean id="ReportBean">
    <description>Executes a report</description>
    <display-name>ReportBean</display-name>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    The `<fixed-outcome>success</fixed-outcome>` strikes me as incorrect -- I don't want the method call to return to another task.
    Restrictions
    The report server receives requests from the web server exclusively. The report server URL cannot be used by browsers to download directly, for security reasons.
    Error Messages
    The error message that is generated:
    Duplicate headers received from server
    Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.Nevertheless, the report is being generated. Preventing the framework from writing the HTTP headers would resolve this issue.
    Question
    How can you set the HTTP headers in ADF while using a Task Flow to generate a PDF by calling a managed bean?
    Ideas
    Some additional ideas:
    - Override the Page Lifecycle Phase Listener (`ADFPhaseListener` + `PageLifecycle`)
    - Develop a custom Servlet on the web server
    Related Links
    - http://www.oracle.com/technetwork/middleware/bi-publisher/adf-bip-ucm-integration-179699.pdf
    - http://www.slideshare.net/lucbors/reports-no-notes#btnNext
    - http://www.techartifact.com/blogs/2012/03/calling-oracle-report-from-adf-applications.html?goback=%2Egde_4212375_member_102062735
    - http://docs.oracle.com/cd/E29049_01/web.1112/e16182/adf_lifecycle.htm#CIABEJFB
    Thank you!

    The problem was that the HTTP headers were in fact being written twice:
    1. The report server was returning HTTP response headers.
    2. The bean was including its own HTTP response headers (as shown in the question).
    3. The bean was copying the entire contents of the report server response, including the headers, into the output stream.
    Firefox ignored the duplicate header errors, but Google Chrome did not.

  • Encoding problem (Umlaute) in HTTP-Headers

    Hi!
    I have a servlet that is being called by another server via a POST request.
    The request contains user data in HTTP-headers, and whenever there is a
    German Umlaut in the user's name, it ends up garbled. :(
    The requests character encoding is set to 'ISO-8859-1', according to the servlet
    requests getCharacterEncoding() method.
    I try to copy the value of a header variable into a String like this:
    headerNameValue = request.getHeader("headerNameKey");Which, unfortunatly, doesn't work. For example, the value "G�nter" becomes "G����nter".
    Shouldn't the API take care of the encoding, when the CharacterEncoding is set
    right in the servlet call?
    It looks like it interprets the ISO88591 data as Unicode?
    BTW, I'm on a WebSphere 5 server, with Java 1.4.
    I've been tearing my hair out on this one for days, so any help is highly appreciated.
    Thanks a lot!
    Andreas

    A header variable with the key 'accept-charset' is not sent.
    Only 'accept-encoding', with the value 'gzip, deflate'.
    Like I wrote in my first post, the servlet request's character encoding is set to ISO-8859-1,
    according to the getCharacterEncoding-method.
    I have kind of solved this for now by converting the String 2times back, like this:
    try {
         headerNameValue = new String((new String(headerNameValue.getBytes(),"UTF-8")).getBytes(),"UTF-8");
    } catch (UnsupportedEncodingException e) {
          logger.error("Fehler beim Umwandeln der Umlaute im Benutzernamen.",e);
    }                    }This code converts the '����', that my servlet receives, back to '�'.
    (The first conversion changes the '����' to '��', the second the remaining '��' to '�').
    While this seems to work, I don't think it is the right solution, and I still don't understand what's going on. :)
    Regards,
    Andreas

  • HTTP headers vs HTTP URLs

    Could someone please explain the very subtle difference between HTTP headers vs HTTP URLs?
    Thanks.

    Hi,
    The URL is the resource location with or without additional parameters that will be requested - e.g. www.cisco.com or http://forum.cisco.com/eforum/servlet/NetProf?page=netprof&needs_authentication=yes&forum=Data%20Center&
    The HTTP headers on the other hand are additional parameters that are part of the HTTP protocol. They define things like Cookies, the referrer etc. A list of headers can be seen at http://en.wikipedia.org/wiki/List_of_HTTP_headers.
    It is also possible to add your own headers - usually prefixed with X-.
    If you look at the dissection of an HTTP conversation captured by Wireshark you'll see how the headers are used.
    HTH
    Cathy

  • [WLS 10.3]:Weblogic.cache.filter does not cache all http headers

    When using Weblogic CacheFilter servlet filter to speed our request. However, cached pages miss
    some HTTP Headers ie: Content-Encoding.
    As a result, if we setup a GZIP filter on most popular static text oriented document like css, html, js, the GZIP filter add a Content-Encoding http header set to gzip. But as CacheFilter forget that header, client receives the correct content-type but not anymore the Content-encoding.
    Steps to Reproduce
    Ask a static file like a .js library and sniff the HTTP headers. Switch the servlet filter order between gzip and CacheFilter, the HTTP header is correctly set but not when putting cache filter first.

    When using Weblogic CacheFilter servlet filter to speed our request. However, cached pages miss
    some HTTP Headers ie: Content-Encoding.
    As a result, if we setup a GZIP filter on most popular static text oriented document like css, html, js, the GZIP filter add a Content-Encoding http header set to gzip. But as CacheFilter forget that header, client receives the correct content-type but not anymore the Content-encoding.
    Steps to Reproduce
    Ask a static file like a .js library and sniff the HTTP headers. Switch the servlet filter order between gzip and CacheFilter, the HTTP header is correctly set but not when putting cache filter first.

  • Get http headers through GenericServlet

    hi ,
    Is it possible to get the http headers through the GenericServlet. I know i can get it through the HttpServlet. Considering that GenericServlet is parent class of HttpServlet I would think that is possible when I get the InputStream - request.getInputStream I should be able to print the headers too. But that does not seem to be happening ? Any information will be appreciated . thanks -sudhir

    Greetings,
    hi ,
    Is it possible to get the http headers through the GenericServlet. I know i can get it through theTechnically, no. Message headers are intended to provide information to the container/encapsulating server relevant to its part in handling the request. Indeed, most headers are not even relevant to the servlet which provides only an "extension" of the server proper. The headers are available in an HttpServlet[Request] primarily because HttpServlets are intended to operate in place of their CGI counterparts (the CGI spec. converts nearly all headers into environment variables...) though not all headers are converted into accessor-enabled object members.
    A GenericServlet, however, is, well, exactly that, "generic". It forms the basis of other protocol-specific implementations (which currently, to my knowledge, includes only HTTP...), and so making those "protocol specific" headers available to an implementation class is the responsibility of the "protocol specific" servlet container.
    However, since you're (presumably) running your "generic servlet" in an HTTP-specific container environment, you can always try casting the ServletRequest object to an HttpServletRequest reference and call getHeader on it. ;)
    HttpServlet. Considering that GenericServlet is parent class of HttpServlet I would think that is
    possibleRefer again to the above.
    when I get the InputStream - request.getInputStream I should be able to print the headers too. But
    that does not seem to be happening ? Any information will be appreciated.Er, no. Input/output streams relate to the body (i.e. the content...) of the message. Headers relate to the meta-data of the message (i.e. its "envelope") - which, again, contains information relevant to the container. That information could be, for example, "routing instructions" - e.g. "Host" or "Referer" headers - or it could be, for example, "handling instructions" - e.g. "Accept-Encoding" or "Cookie" headers.
    In the former case, the headers are mostly of relevance only to the container, though a servlet may also base some part of its processing on them and so they are made accessible through the getHeader method.
    In the latter case, they are not necessarily relevant to either (the container or the servlet) though, when relevant, they are most likely relevant to the servlet - whether implicitly ("Accept-Encoding") or explicitly ("Cookie") - and so are made available either in the same "implicit" fashion (getHeader), or through a more "explicit" API call (getCookies).
    thanks -sudhirRegards,
    Tony "Vee Schade" Cook

  • Changing http headers using handlers

    Is there anyway to access and set http headers using handlers? I took a look at the documentation and wasn't able to find a way to modify the http headers. Only SOAP related stuff. Need to go more low level.

    Access the header by getting the HttpServletRequest object as follows:
    handleRequest(MessageContext mc)
    Object obj = mc.getProperty("weblogic.webservice.transport.http.request");
    if(obj != null && obj instanceof javax.servlet.ServletRequest) {
                   request = (HttpServletRequest) obj;
    request.getHeader("Name of Header");
    That'll get you the request header.
    I'd imagine you could do the same in a handleResponse method if what your trying to do is set a response header.

  • HTTP Headers - enabling caching and compression with the portal?

    Has anyone configured their web server (IIS or Apache) or use a commercial product to flawlessly cache and compress all content generated by the portal?
    Compression and caching is critical for making our portal based applictions work for overseas users. It should be doable, just taking advantage of standard HTTP protocols, but implementing this a complex system like the portal is tricky, we seem to be generating different values in the HTTP Headers for the same types of files (such as CSS).
    We are running Apache so can't take advantage of the built in compression capabilities of the .net portal. We are running the java vervion. 6.1 mp1, sql server 2000 (portal, search, collab, publisher, studio, analytics, custom .net and java portlets on remote server).
    Basically our strategy is to compress all outgoing static and dynamic text content (html, CSS, javascript), and to cache all static files (CSS, javascript, images) for 6 months to a year depending on file type.
    Here are some links on the subjects of caching and compression that I have compiled:
    Caching & Compression info and tools
    http://www.webreference.com/internet/software/servers/http/compression/
    http://www.ibm.com/developerworks/web/library/wa-httpcomp/
    http://www.mnot.net/cache_docs/
    http://www.codeproject.com/aspnet/HttpCompressionQnD.asp?df=100&forumid=322472&exp=0&select=1722189#xx1722189xx
    http://en.wikipedia.org/wiki/Http_compression
    http://perl.apache.org/docs/tutorials/client/compression/compression.html
    https://secure.xcache.com/Page.aspx?c=60&p=590
    http://www.codinghorror.com/blog/archives/000807.html
    http://www.howtoforge.com/apache2_mod_deflate
    http://www.ircache.net/cgi-bin/cacheability.py
    http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching/
    http://betterexplained.com/articles/speed-up-your-javascript-load-time/
    http://betterexplained.com/articles/speed-up-your-javascript-load-time/
    http://www.rubyrobot.org/article/5-tips-for-faster-loading-web-sites
    http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
    http://www.gidnetwork.com/tools/gzip-test.php
    http://www.pipeboost.com/
    http://www.schroepl.net/cgi-bin/http_trace.pl
    http://leknor.com/code/gziped.php?url=http%3A%2F%2Fwww.google.com
    http://www.port80software.com/surveys/top1000compression/
    http://www.rexswain.com/httpview.html
    http://www.15seconds.com/issue/020314.htm
    http://www.devwebpro.com/devwebpro-39-20041117DevelopingYourSiteforPerformanceCompressionandOtherServerSideEnhancements.html
    http://www.webpronews.com/topnews/2004/11/17/developing-your-site-for-performance-optimal-cache-control
    http://www.sitepoint.com/print/effective-website-acceleration
    http://nazish.blog.com/1007523/
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/IE_Fiddler2.asp?frame=true
    http://www.fiddlertool.com/fiddler/version.asp
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
    http://www.web-caching.com/cacheability.html
    http://www.edginet.org/techie/website/http.html
    http://www.cmlenz.net/blog/2005/05/on_http_lastmod.html
    http://www.websiteoptimization.com/speed/tweak/cache/
    http://www.webperformance.org/caching//caching_for_performance.html
    http://betterexplained.com/articles/how-to-debug-web-applications-with-firefox/
    Edited by tkoenings at 06/18/2007 6:26 AM

    Hi Scott,
    Does Weblogic platform 8.1 supports netscape? We have developed a portal which
    works perfectly on IE but it dies in netscape. Is netUI tags not supported in
    Netscape?
    Pls reply
    manju
    Scott Dunbar <[email protected]> wrote:
    From a pure HTML perspective Portal does it's rendering with nested
    tables.
    Netscape 4.x and below have terrible performance with nested tables.
    The
    problem is not the Portal server but rather Netscape on the client machine.
    If IE and/or a recent version of Netscape/Mozilla is not possible then
    there are
    really only two options:
    1) Faster client hardware - not likely to be an acceptable solution.
    2) Minimize the number of portlets and the complexity within the portlets.
    Neither of these solutions are a great answer, but the 4.7 series of
    Netscape is
    getting pretty old. Having said that, we've got customers who want to
    continue
    to use IE 4 :)
    Again, though, this problem is, I'm afraid out of our hands. It is the
    client
    rendering time that is the issue.
    cg wrote:
    Does anyone know of any known reasons why the 7.0 (did it also with4.0) portal
    pages can take up to almost 30 seconds to load in Netscape 4.7? I knowit is a
    very generic question but our customer still uses 4.7 and will notuse the portal
    b/c it takes so long to load some of the webapps. What the pages willdo when
    loading is that the headers will come up and when it gets to the bodyof the page
    it seems to stall and then comes up all of a sudden. For some of thepages it
    takes 6 seconds and for others it takes about 24-27 seconds.
    We have suggested using IE only but that is not an option with allof the customers
    and getting a newer version of Netscape is also out of the question.
    Any suggestions would be greatly appreciated.--
    scott dunbar
    bea systems, inc.
    boulder, co, usa

  • Acrobat Reader X stores PDFs in Temp-folder even when HTTP-headers say no-cache no-store

    After updating from Acrobat Reader 9 to 10 we have noticed that PDFs viewed in the browser are left behind in the Temp-folder even after the browser has been closed.
    Http-headers in the response from the server
    Cache-Controls: no-cache,no-store,max-age=0,post-check=0,pre-check=0
    Content-Type: application/pdf
    Content-Disposition: inline; filename="xxxxxxxx.pdf"
    Expires: 0
    Pragma: no-cache
    Folder: [User-folder]\AppData\Local\Temp
    Filename-format: PDFxxx.tmp
    Browsers: Firefox 3.6, Opera 11, Safari 5
    Plugin: Acrobat Reader 10
    Simply add a .pdf extension to the file and open again in Acrobat Reader. Since the server has set headers indicating that this PDF should not be stored locally, it is a severe security hole leaving traces of this PDF on the filesystem.
    Is this a problem Adobe is aware of? When can we expect this to be fixed?
    Regards,
    Gustav

    Hi Michael,
    Thank you for you quick response!
    In Acrobat 9, I cannot find the PDFs in the Temp-folder after the browser has been closed.
    In Acrobat 10, PDFs are left behind in the Temp-folder even after browser close.
    To me, this looks like a bug in Acrobat 10. Would you not agree?
    Regards,
    Gustav

  • Using custom http headers in SOAP sender adapter

    Hi,
    my problem is exactly the same as reported [here|Re: SOAP Sender - Extract Header Values;] and [here|Variable Transport Binding - Soap Sender;
    Basically I'd like to send through the soap sender adapter some custom http headers. I check the necessary options in the advanced tab (set adapter-specific message attributes and variable transport binding), and in the variable header one I put x-StoreCode, which is the same http header I send to PI.
    But I won't see anything in the dynamic configuration section when the message is persisted in PI.
    Very surprised that I've seen this issue is a common problem others have faced before without success.
    Thanks!

    Hi Michal,
    the extra info I'm trying to send separated from the message is an http header, not part of the query string.
    If I incorporate the extra info as a parameter to the query string like this, for example:
    http://host:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=S1&receiverParty=&receiverService=&interface=Int&interfaceNamespace=urn:test&x-StoreCode=13&nosoap=true
    Then I can see the value in the dynamic configuration section:
    <SAP:Record namespace="http://sap.com/xi/XI/System/SOAP" name="SQueryString">senderParty=&senderService=S1&receiverParty=&receiverService=&interface=Int&interfaceNamespace=urn:test&x-StoreCode=13&nosoap=true</SAP:Record>
    But what I'm trying to do shoould be possible, according to sap help:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/fc/5ad93f130f9215e10000000a155106/content.htm (section Define Adapter-Specific Message Attributes)

  • Biztalk 2013 WCF-WebHTTP Adapter - Outbound HTTP Headers

    Hi
    I have a requirement to connect to a service using the WCF-WebHTTP adapter that requires authentication to be passed in the Headers.
    A usercode and password is sent in the intial header and a security token is returned in the response header.
    This security token is then used in the header of each subsequent call to the service.
    I could not find anything in the documentation about getting and setting the "HTTP Header" data using maps or variables or using variables in the "Outbound HTTP Headers" on the adapter transport properties.
    Any help on this would be gratefully received.
    Malcolm

    You can set the outbound HTTP header in WCF-WebHTTP adapter by 2 ways
    1) At adapter level Change adapter properties
    2)Changing Message context property at Orchestration or at pipeline
    Its been well documented here
    http://blog.codit.eu/post/2013/04/30/Using-HttpHeaders-with-WCF-WebHttp-Adapter-on-Biztalk-2013.aspx
    Thanks
    Abhishek

  • Exclude http headers from reponse??

    Hi all,
    I post data to a server and get response[in xml] back like this
    Socket theSock = new Socket(serverhost,80);
    PrintStream ps = new PrintStream(theSock.getOutputStream());
    ps.println("POST /url HTTP/1.0");
    SAXBuilder builder = new SAXBuilder(); //==<< get reponse
    Document doc = builder.build(theSock.getInputStream());
    .at builder.build I've got "SAXException: Parsing Error : The root element is required in a well-formed document" .
    that because output from theSock.getInputStream() is
    HTTP/1.1 200 OK
    Date: Wed, 04 Jul 2007 10:14:54 GMT
    Content-Length: 105
    Content-Type: text/xml;charset=UTF-8
    Connection: close
    <resp>
    <status>200</status>
    <description>ok</description>
    </resp>I know that if i use HttpURLConnection the response InputStream will not contain http headers. But I'm just curious that with Socket, Is there any trick to get only content from InputStream?

    There is no trick except to use the HttpUrlConnection class. That�s why it was created. It wraps the socket and parses through the headers for you. The socket is very low level and all it sees are bits over an input stream (TCP / UDP). It does not know or care about HTTP which is a protocol on top of TCP.

  • Http header setting in servlet

    Hello,
    I want to set the header parameters of http response in my servlet.
    I set parameters as below:
              theResponse.setHeader("Request Version", "HTTP/1.1");
              theResponse.setStatus(200);
              theResponse.setHeader("Date", "Wed, 18 Apr 2007 09:24:04 GMT");
              theResponse.setHeader("Server", "Tomcat");
              theResponse.addCookie(theRequest.getCookies()[0]);
              theResponse.setHeader("pragma", "no-cache"); // HTTP 1.0
              theResponse.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
              theResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // a past date
              theResponse.setDateHeader("Last-Modified", (new java.util.Date()).getTime());
              theResponse.setHeader("Connection", "close");
              theResponse.setContentType("text/plain");
    //some other things...
              PrintWriter aPrintWriter = theResponse.getWriter();
              aPrintWriter.write("this is the string to be put into the body part of the http packet.");
    However, I am checking what I am sending as response using the ethereal network sniffing tool and seeing the result below:
    HTTP/1.1 200 OK\r\n
    Request Version: HTTP/1.1
    Response Code: 200
    Server: Apache-Coyote/1.1\r\n
    Content-Length: 68\r\n
    Date: Tue, 24 Apr 2007 17:55:10 GMT\r\n
    \r\n
    Data (68 bytes)
    I am setting header parameters as it should be.. But it doesn't care about my parameters and Tomcat puts some values that it selects..
    Where is my fault? Can anyone recommend sth please..? I am really stucked here..
    Thanks & Regards

    Hello,
    It looks like your question is really related to Tomcat (coyote). However if you want to control the server name on OC4J you can do it, see this blog entry:
    - OC4J tip: changing the server information
    Regards
    Tugdual Grall

  • HTTP Headers for SOAP

    Hello,
    I need to set some custom HTTP Header when i send the SOAP message to an endpoint.
    I tried this..but doesn't solve my requirement.
    SOAPMessage soapmsg = messageFactory.createMessage();
    MimeHeaders mime = soapmsg.getMimeHeaders();
    mime.addHeader("SOAPAction", "xxxx");
    mime.addHeader("Sender", "yyy");
    SOAPMessage reply = connection.call(soapmsg, destination);
    Can anyone please guide me how to set HTTP headers for SOAP?
    Thanks,

    Hello,
    I need to set some custom HTTP Header when i send the SOAP message to an endpoint.
    I tried this..but doesn't solve my requirement.
    SOAPMessage soapmsg = messageFactory.createMessage();
    MimeHeaders mime = soapmsg.getMimeHeaders();
    mime.addHeader("SOAPAction", "xxxx");
    mime.addHeader("Sender", "yyy");
    SOAPMessage reply = connection.call(soapmsg, destination);
    Can anyone please guide me how to set HTTP headers for SOAP?
    Thanks,

  • Firefox is trying to send strange multiple requests on port 7070. As I allow the request nothing appears in "http headers" addon window. What could this be?

    Hi.
    I discovered my Firefox v26 was SOMETIMES trying to send multiple requests on port 7070 (ukrainian ip-address) independently on what websites were opened at the moment.
    The problem remains after v27 update.
    I have an addon "live http headers" installed.
    As I manually allow the request by firewall nothing appears in the headers window.
    Does my firefox seem to be modified with adware/spyware?

    Have you tried Opening your Firefox in Safe Mode
    [[Troubleshoot Firefox issues using Safe Mode]]
    please report back to us

Maybe you are looking for

  • Mac mini and compatibility of peripherals

    Hi, a friend of mine is giving me his old Mac mini. I'll need to get a keyboard, mouse and monitor. I'm looking at non-apple products. He says that any mouse, keyboard and monitor would be compatible with the mini, but I thought that only some periph

  • What will happen if I open an .ear file on the OAS OC4J_Portal/applications

    Hi, Is it possible to open an .ear file in another directory of OC4J_Portal instance with UNIX as the flavour. If so what would happen?

  • Convert ABAP list output to PDF without spool

    Hi All, We have used the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' to convert the list output to PDF. It creates the spool number in SP01 and PDF is getting generated. But, in our SAP ECC 6.0 server all spools are redirected to printer by default and get print

  • Shipping from China?

    Purchased my 16 MB IPOD touch yesterday off the Apple web site. Got a fed ex tracking number and it's being shipped in from China. I know they are built in China, but I just find it odd that they have no domestic supply facility in the US to ship it

  • Adaptive Resolution while adjusting mask path

    This is something that has been driving me crazy for a while. Whenever I adjust a mask path, the resolution of the preview window drops to 1/2 and displays the words "Adaptive Resolution (1/2)" appear in the top right corner of the preview window. Th