Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
I/O and Streams
XML writing and reading to an URl
Ajith George
Ranch Hand
Posts: 109
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i was trying to submit xml data to a url. and try to read the same using stream reader. But as i read the server is returning internal server error. i am attaching the code here.
try{ //find the right MIME type and set it as contenttype response.setContentType("text/xml"); //InputStream in = null; URL url = new URL("http://192.168.11.74/Enam/Pages/PortfolioXRayReport/PortfolioXRay.aspx"); HttpURLConnection urlc= (HttpURLConnection)url.openConnection(); urlc.setDoOutput(true); OutputStream os=urlc.getOutputStream(); PrintWriter pw = new PrintWriter (os); pw.print(serviceRequest); InputStream in=urlc.getInputStream(); int i=0; while((i=in.read())!=-1){ System.out.println((char)i); }// } catch (Exception e) { e.printStackTrace(); ErrorStr = "Error Streaming the Data"; // pw.print(ErrorStr); }
Please help me out.
Thanks in advance.
SCJP 1.4, Brainbench
LinkedIn
-
Blog
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Since it's the server that's crashing, it's the server that has the problem -- at least in its error handling, if not more.
But you can might start by flushing and closing the PrintWriter before trying to read the response!
[Jess in Action]
[AskingGoodQuestions]
Ajith George
Ranch Hand
Posts: 109
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i flushed and closed the print writer ......but the result same. Is there any other way to read the response. Am i doing it right?
SCJP 1.4, Brainbench
LinkedIn
-
Blog
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Read XML output from a URL
Unable to access URL using HttpURLConnection
Unable to read the Japanese character from HTTP Response
servlet response
Streaming PDF, Connecion Error
More...