---- Original Message -----
From: "Ashwini Bhat" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
> public class AppServlet extends HttpServlet{
> DataInputStream dis;
> DataOutputStream dos;
> URL url;
> URLConnection con;
> String s,s1;
Declaring member variables which are mutated per request is not a good
practice unless you syncronize on these variables but this should not be the
cause of the exception you are getting.
[snipped]
> con.setUseCaches(false);
>
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
The HTTP header that you are trying to set is "CONTENT-TYPE" and not
"CONTENT_TYPE" as you have set.
> con.setDoInput(true);
> con.setDoOutput(true);
The moment you say setDoOuput(true), on Suns JVM,the http method is changed
to POST. Now when you are making a POST request, you are supposed to send
the content-length of the body by setting the header *Content-Length* which
you are not sending. This will result in an error, but I think you never
reached here. You have not posted the stack trace of the exception, but I
feel it is generated before you reach this line of code.
> The simple class is as follows
[snipped..]
> //CONNECTING TO THE SERVLET APPSERVLET.
> con=url.openConnection();
> con.setUseCaches(false);
>
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
The HTTP header that you are trying to set is "CONTENT-TYPE" and not
"CONTENT_TYPE" as you have set.
> con.setDoInput(true);
> con.setDoOutput(true);
Here you do setDoOutput(true) which sets the method type to POST. Hence it
is a good idea to set the Content-Length header.
> con=url.openConnection();
> con.setUseCaches(false);
> con.setDoInput(true);
> con.setDoOutput(true);
>
con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
Have you have pasted the above section of the code twice, or it appears
twice in the orignal code also !!
Also, as you have set the Content-Type of the request as
"application/octet-stream", the container should not parse the body of the
request for the parameters. The container should parse the body of the
request only when the content-Type is "application/x-www-form-urlencoded".
Can you check if you are still getting the error after changing
"CONTENT_TYPE" to "CONTENT-TYPE".
Regds,
Gokul
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html