• 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

Problem in URL Concept(need help urgently)

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I want to know, how to keep the connection alive after sending the first request. i used the following stmt
setRequestProperty("Connection","Keep-Alive"). but still the connection is closed after first request . Iam using HTTP/1.0.
Can anyone tell me a way to keep connection alive until I specify it to close?

Using URL, we establish connection with a server to particular file. Is there any method in HttpURLConnection or URLConnection where u can specify the file to access rather than specifying the file name at the time of connection.So that I can make multiple request to access different file each time.
I need it urgently .
Thanks in advance,
Deepa Raghuraman
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, keepalive is only supported by HTTP 1.1. If you are really using 1.0 then it will never work.
Second, I understand (but have not verified) that keepalive is transparently supported by the URL class since JDK 1.3. See the networking enhancements (bottom).
Finally, to retrieve a different file you need to instantiate a different URL. This should not interfere with the keepalive feature, but again, I've never verified this.
Keepalive is controlled by the http.keepAlive system property. This was first properly documented in version 1.4 of the SDK.
- Peter
 
Deepa Raghuraman
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Thanks for replying. In java.sun.com site, i read that HTTP1.0 by default has Connection : close which can be made presistance connection using Keep-Alive and HTTP1.1 by default has Connection : keep-alive.
According to ur reply,HTTP1.0 closes the connection after each request and keep-alive cannot be used in it.
Can u tell be how to upgrade HTTP1.0 to HTTP1.1?I need to keep connection presistant until client says explicitly to close.
It would be very helpful if reply it soon.
Thanks,
Deepa Raghuraman
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Deepa Raghuraman:

I need to keep connection presistant until client says explicitly to close.


this can't be done from client side until and unless web server supports and thus respond with "Connection : Alive" instead of "Connection : closed" client can only request to keep alive the connection, but final decission is taken by web server.

Originally posted by Deepa Raghuraman:
hi,
Can u tell be how to upgrade HTTP1.0 to HTTP1.1?


just use higher version of jdk like 1.4 to make java.net.URLConnection , thats all.



[ May 03, 2002: Message edited by: gautam shah ]
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Deepa Raghuraman:
In java.sun.com site, i read that HTTP1.0 by default has Connection : close which can be made presistance connection using Keep-Alive and HTTP1.1 by default has Connection : keep-alive.
According to ur reply,HTTP1.0 closes the connection after each request and keep-alive cannot be used in it.

Although the HTTP 1.0 specification (RFC 1945)did not specify a keep-alive feature, some (but not all) servers did implement an experimental version. According to RFC 2068 19.7.1 these implementations were faulty, and if you want keep-alive you should really be using a HTTP 1.1 server and client.
- Peter
 
Deepa Raghuraman
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
how would i know which version of HTTP I am using.Is there any method which specific the HTTP version? As u mentioned using higher version of Jdk i.e., 1.4 I can have HTTP1.1. But when
I mention HTTP/1.1 the server responsed as "server cannot under the request sent by the HTTP1.1 client and the hostname is missing. I had pass the Host header along with the request. I am using JDK1.4.
thanks in advance,
Deepa Raghuraman
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic