Andy,

Try putting a URLConnection connect() method in the app code after the
writeObject.
I would also recommend a flush() on the object output stream as well,
between the
writeObject and the connect calls. See code added below.

This is almost a bug in URLConnection, you would expect getInputStream to
establish
the connection if it not already established.

Hope this helps!

Merry Christmas,

Rob Griffin
[EMAIL PROTECTED]
Quest Software
http://www.quest.com


> -----Original Message-----
>
>
> I am having a problem communicating with a servlet using URLConnection.  I
> am running WinNT SP4 IIS4 and JRun 2.3.3.  I have no problem getting the
> outputStream from the servlet and sending an object to the
> servlet, but once
> I try to get the inputStream I get the following error:
>
> "java.io.FileNotFoundException: http://javadev/servlet/TestServlet"

[snip]

> App Code:
>
> import java.io.*;
> import java.util.*;
> import java.net.*;
>
> public class TestApp {
>
>     public void init(){
>
>         try {
>         String testOutput = "This is test output";
>             URL url = new URL("http://javadev/servlet/TestServlet");
>             URLConnection con = url.openConnection();
>             con.setUseCaches(false);
>
> con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
>             con.setDoOutput(true);
>             con.setDoInput(true);
>             System.out.println("Still working");
>             ObjectOutputStream oos = new
> ObjectOutputStream(con.getOutputStream());
>         oos.writeObject(testOutput);
*************************************************
              oos.flush();
              con.connect();

*************************************************
>             System.out.println("Got the Output");
>             ObjectInputStream ois = new
> ObjectInputStream(con.getInputStream());
>             String test = (String)ois.readObject();
>             System.out.println(test);
>         }
>         catch(Exception e){
>             System.out.println(e.toString());
>         }
>
>     }
>
>     public static void main(String[] args){
>         TestApp test = new TestApp();
>         test.init();
>     }

___________________________________________________________________________
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

Reply via email to