• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Call to Servlet with InputStream from application

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
From an Java-application I want to call a servlet with a post request that includes a text-file
in the inputstream.
How do I do that ? I tried the following,but I'm confused about how the servlet can read the stream .
URL url = new URL("http://plovdinger:80/xmlReceiver");
URLConnection uc = url.openConnection();

uc.setDoOutput(true);
OutputStream os = uc.getOutputStream();

OutputStream buf = new BufferedOutputStream(os);
OutputStreamWriter out = new OutputStreamWriter(buf,"8859_1");
out.write("one little line\r\n");
out.write("Two little line\r\n");
out.flush();
out.close();

//return the response
readInputStream(uc.getInputStream());
 
He's giving us the slip! Quick! Grab this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic