Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to open file whose path starts with http://  RSS feed

 
swap Inam
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I am using following code to open a file.
It works properly when the file path is
given as file://server/path/filename.
But when file path is given as
http://server/path/filename it gives the error
"java.io.IOException: Server returned HTTP response code: 502 for URL: http://ind
-spz7w2s0023/CLASDocs/Out/NESHB.pdf
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at lex.quotes.control.SDocumentDisplayController.service(SDocumentDispla
yController.java:79)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterC
hain.java:59)
at lex.efm.authentication.SCheckSessionFilter.doFilter(SCheckSessionFilt
er.java:160)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:375)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:170)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:576)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:189)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)"

The code is as seen below :

URL url = null;
URLConnection con = null;
url = new URL(strURL.toString());
con = url.openConnection();
response.setContentType("application/pdf");
PrintWriter out = response.getWriter();
String inputLine;
StringBuffer messageLog = new StringBuffer();
BufferedReader bfReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
while (null != (inputLine = bfReader.readLine()))
{
messageLog.append(inputLine + System.getProperty("line.separator"));
}
bfReader.close();
out.print(messageLog.toString());
out.close();
TIA
Swapnil
 
Eric Cartman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Server returned HTTP response code: 502
This means that the server you are connecting to is overloaded and thats why you cant retrieve the doc.
EC
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!