Monte,
There doesn't seem to be a compelling reason to use a servlet in your
application since a browser doesn't seem to be involved. Have you
considered using RMI? It may be a more direct solution. You would just
invoke a class method on the server with an int as a parameter. The method
would then return an int.
Regards,
Richard
At 04:05 PM 11/28/2001 -0700, you wrote:
>I'm trying to write an application consisting of a
>client side application and a Server side Servlet.
>To start out, the client is supposed to send an
>integer to the Servlet, and then the
>Servlet is supposed to send an Integer back.
>
>
>this is the important part of the service method my Servlet is using
>
>
> OutputStream out = response.getOutputStream();
> InputStream in = request.getInputStream();
> DataInputStream dataIn = new DataInputStream(in);
> DataOutputStream dataOut = new DataOutputStream(out);
> int requesttype;
> requesttype = dataIn.readInt();
> //write the integer received to a file
> tolog("Request : " + requesttype);
> dataOut.writeInt(ScrapBookProtocol.VALID);
>
>
>this is the code the client is using to make the connection to the servlet.
>
> String path
> ="http://www22.addr.com/~mgardne/servlets/ScrapBookServer";
> URL servletURL = new URL(path);
> URLConnection connection = servletURL.openConnection();
> connection.setUseCaches(false);
>
>
>connection.setRequestProperty("CONTENT_TYPE","application/octet-stream");
> connection.setDoInput(true);
> connection.setDoOutput(true);
> //make request
> OutputStream out = connection.getOutputStream();
> InputStream in = connection.getInputStream();
> DataOutputStream dataOut = new DataOutputStream(out);
> dataOut.writeInt(ScrapBookProtocol.GETSCRAPBOOK );
> out.flush();
> out.close();
> //read response
> DataInputStream dataIn = new DataInputStream(in);
> int vc = dataIn.readInt(); //**exception occurs here!!
> System.out.println("Validation Code Received: " + vc);
>
>When I run the client side program I get a java.io.EOFException, at the call
>to dataIn.readInt(), which seems to indicate that the server isn't sending
>anything back.
>Also, the call to toLog() should write the integer that the client sent to a
>log file, and
>nothing is getting written there. So, I'm either not making a connection at
>all, or the
>Servlet is not sending anything back. Am I missing anything here? What is
>the correct way
>of sending integers back and forth between a program and a servlet??
>
>
>
>--Monte Glenn Gardner
>
>___________________________________________________________________________
>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
___________________________________________________________________________
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