• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

writing output after input in data streams

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I am writing a console application to send multiple requests to the Northwest Airlines web server. As soon as I send a query string, I receive a page having a meta tag giving the url of the page where the request could be redirected. I am using the same urlConnection to first send my request, get the output from the server, then send back the query to the new url and get the page having the final result.
However, I am getting the following exception:
Exception in thread "main" java.net.ProtocolException: Cannot write output after reading input.
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
Can anybody help me out with how to take care of this,
Thanks,
Sid
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Exception in thread "main" java.net.ProtocolException: Cannot write output after reading input.
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)


Your connection object should be new for every request.
Eugene.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, you need a new connection. Rest assured, though, that behind the scenes Java will use HTTP keepalive if possible.
- Peter
 
Siddesh Kamat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter and Eugene,
Thanks a lot...
Sid
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm already using an Http Tunneling between an applet and a servlet... All work fine without session tracking. Actually, I want to keep the session tracking between the both side. Unfortunately if I reset the connection for every request all the session information will be loosed!
Have you an idea to resolve that?
Thanks a lot,
Slamer
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Slamer Slamer:
Hi,

I'm already using an Http Tunneling between an applet and a servlet... All work fine without session tracking. Actually, I want to keep the session tracking between the both side. Unfortunately if I reset the connection for every request all the session information will be loosed!
Have you an idea to resolve that?
Thanks a lot,
Slamer



i have the same problem.

frequent openConnection will affect performance?

anybody can tell me how to do the above question.

i need your help.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Session id is stored in the cookie. after reset connection, you must send that cookie to the server
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic