File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Setting Content-type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting Content-type" Watch "Setting Content-type" New topic
Author

Setting Content-type

iceman
Greenhorn

Joined: Oct 12, 2001
Posts: 5
I am trying to set the content type in this code:
but the remote server say's the content type is not being set? any Idea's
note:
XMLDATA contains a correctly formated XML file
---- Snip code
BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream()));
Writer out = new OutputStreamWriter(socket.getOutputStream());
out.write ("POST https://www.domain.com/apps/Urel\r\n");
out.write("Content-type: text/xml"\r\n);
out.write("XMLDAT"\r\n");
out.write("\r\n");
out.flush();

----- Snip code
I have also try out.write(Content-Type, text/xml\r\n");

Thanks for any help


William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Since you are writing headers "by hand" remember there needs
to be a blank line between the headers and the content. Looks to me like you are writing XMLDAT directly after the headers.


Java Resources at www.wbrogden.com
iceman
Greenhorn

Joined: Oct 12, 2001
Posts: 5
Hmmm.. Thanks for the help, But I still get the same error.
This is what I have for the headers
String header = "Content-Type:, text/xml\r\n";
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
You need to do the following
In a doPost use the request parameter
such as

request.setContent("Content-Type", "text/html");
etc
etc
Good luck


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Content-type
 
Similar Threads
java to php
Tomcat madness!
Problem with xmlhttp.responseXML
Java Http Server and Java Http Client
jsp:setProperty question