• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

URLs

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I have actually two questions on the following link at another forum but i am not getting any responses from it. Maybe someone can have a look at the link and post any responses here.

Here is the link

http://forums.devshed.com/t277542/s.html

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

Sorry about only leaving a link. I got an e-mail from someone saying that its better if i posted thge question here than they going back forth. Anyways here are the two questions

I have two rather silly questions about URLs but please bear with me for a while.

Usually when you use the URLConnection class to read from a website you don't get prompted for authentication but if you are trying to post something to that website you will usually require some kind of authentication.

Please assume that the authenticator class has been set correctly and that its getPasswordAuthentication() method returns the correct username and passsword

Consider this code



My problem is now i do not know that if i am going to post to that website(and it most certainly will need authentication) will i be prompted by the Authenticator class so i can get the outputstream and post to that website

I am not able to test this code because i currently do not have any website to post to but i am working on an application that could possibly do this.

On another question lets say i am reading from a website that has a zip file say www.yahoo.com/my_life_story.zip

Now if i do this am i right??



Now in above code i am reading stream bytes but if i were using the PrintReader and putting the output to the console you would see all the server html commands and the byte content of the file but as rubbish text.

Now basically my question is when i read that file as stream bytes and save it to disk will all the html commands also be saved because that's not what i want. I only want the zip file.

I hope someone can help me with the above two questions

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should consider using Jakarta HttpClient. It offers a simple-to-use API that can handle file downloads and HTTPS.
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I can't use the Jakarta HttpClient because i need something that uses the Java URL class. I know it sounds stupid but at this point of time i really have keep things simple.

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
Steve Morrow
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't want to use any other libraries, you'll need to roll your own parser to handle the servlet response. What questions do you have about how to do this?
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI everyone,

Steve currently i may start to roll out my own parser but before i can start i need to know how the Java URL class handles its url ouputstream and inputstream.

First do the streams if read as bytes include only the content of the website??

or

does it include the servers response together withe the content of the website??

Steve please consider the below code



Now my question is when i read that file as stream bytes and save it to disk will all the server commands also be saved because that's not what i want. I only want the zip file.

Did you experience such thing before when you tried to download any file from a url using the URL class with java while getting its stream??

If you did is there a way to overcome it??

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic