• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLConnection - - FileNotFoundException

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does someone know this problem?
I�m having a FileNotFoundException when get a InputStream in a URLConnection.
The connection with the server is OK. I�m not having any problem to write the output in the server, but when I try to get the InputStream I�m having the problem above.
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you used
UrlConnection.setDoOutput(true);
and
UrlConnection.setDoInput(true);
According to the docs, if you setDoOutput(true), then this defaults setDoInput(false) which means that you can't getInputStream on the URL connection.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I bet you are doing a GET or POST to a servlet or JSP page. If it's a servlet, you will probably want to make sure that you specifically close the output stream with
HttpServletResponse.getWriter().close()
If it's a JSP page, check to make sure that you aren't getting an exception which never forwards to an error page. I'm not sure, but I think if the servlet sets the HTTP status to anything higher than 2xx, (such as the 500 that a JSP page generates if there is an uncaught error), URLConnection will complain about a FileNotFoundException.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup. We were having this problem with WebSphere 4.0. Struts actions that worked under Tomcat and WebLogic broke all of a sudden under WebSphere 4.0. If you're going to do an HttpServletResponse.getOutputStream() and write to it, flushing the stream isn't enough; you have to close the stream before your action returns, or you'll get a 500.
- James
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
I have this problem FileNotFound the 500 but I do not understand how you
propose to solve it if you could please be more clear, I want to
you that I am under Tomcat,

and i want to get an xml file and do and out.println on it after getting it... i'm really in need of help

thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic