Bonjour! I also thought that this could be the answer to my problem but I
previously try it and it didn't change anything so I'd remote it. Just to
be sure, I just retry it (adding doinput(true) after the dooutput
statement) and obtain the same exception...
Thanks for the try,
Stephane
>I think you need to do an url.setDoInput(true) to fix the problem. The
>javadoc of URLConnection says:
>
> "A URL connection can be used for input and/or output. Set the DoInput flag
>to true if you intend to use
>the URL connection for input, false if not. The default is true unless
>DoOutput is explicitly set to true, in
>which case DoInput defaults to false."
>
>Since you do set the DoOutput flag to true its normal to get an exception.
>
>When you try to get the InputStream it is supposed to throw you an
>IOException. FileNotFoundException is an IOException but it's kinda strange
>to throw that particular one from an URLConnection !!!!
>
>
>Hope this helps,
>
>Philippe Lamy
>TouchTunes Digital Jukebox
>
>
>
>
>Stephane Cloutier wrote:
>
>> I hope somebody could explain me this weird problem... I have a servlet who
>> must send requests to another servlet. I choose to do this with an
>> URLConnection object. I create an OutputStream and write my parameters and
>> values into it. After that, I create an InputStream to read the return
>> page (I didn't really need to read the page but it seems necessary to get
>> done the redirection that is performed at the end of the second request
>> call). This was working with servletrunner of jsdk2.0 but it doesn't work
>> with JRun and resin that I actually use. It throw a FileNotFoundException
>> on the second servlet URL when getting the inputstream!?
>>
>> I seriously think to do this with RequestDispatcher, but I'll be very happy
>> to be enlighten on this since I don't understand why a file exception for a
>> url?? Below is the code I use to make the communication between the 2
>> servlets...
>>
>> Thanks,
>> Stephane Cloutier
>>
>> URLConnection url = servlet.openConnection();
>> url.setDoOutput(true);
>> PrintWriter out = new PrintWriter(url.getOutputStream());
>> out.print("parameter1=value1");
>> out.print("parameter2=value2");
>> out.print("parameterX=valueX");
>> out.close();
>>
>> InputStream istream = null;
>> try
>> {
>> istream = url.getInputStream();
>> }
>> catch(Exception e)
>> {
>> e.printStackTrace();
>> }
>> InputStreamReader ireader = new InputStreamReader(istream);
>> BufferedReader in = new BufferedReader(new
>> InputStreamReader(url.getInputStream()));
>>
>> String inputLine;
>> while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
>> in.close();
>>
>> ___________________________________________________________________________
>> 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
___________________________________________________________________________
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