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"

Any help would be great!!

Andy

***********

Here is the code for the servlet and app:

Servlet code:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class TestServlet extends HttpServlet {

  public void init(ServletConfig config)
        throws ServletException {

        super.init(config);
  }

  public void service(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {

        try{
            String test = "This is a test";
        ObjectInputStream ois = new
ObjectInputStream(request.getInputStream());
        String testInput = ois.readObject();
            response.setContentType("application/octet-stream");
            ObjectOutputStream oos =  new
ObjectOutputStream(response.getOutputStream());
            oos.writeObject(test);
            oos.flush();
            oos.close();

        }
        catch(Exception e){

        }
    }

    public String getServletInfo() {

        return "StudentListTunnelServlet Information";
    }

}

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);
            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