aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Get the temp file(css and image) from the response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Get the temp file(css and image) from the response" Watch "Get the temp file(css and image) from the response" New topic
Author

Get the temp file(css and image) from the response

yu yong
Ranch Hand

Joined: Mar 09, 2008
Posts: 44
Hello topicers
I need your help.
In my project, I use the HttpClient to mock the request. And get the response from PostMethod.
I want to get the css and image files from the response stream.
Can I get it? And how .

Thanks,
Yours


Yours sincerely,<br />yuyong<br /> <br /> <br /> E-mail:yuyong22@hotmail.com<br /> msn: yuyong22@hotmail.com<br /> Skype:yuyong88
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

If you need to parse the HTML, you can use something like TagSoup and create your own org.xml.sax.helpers.DefaultHandler to parse the links. Something like this, with more complicated handling for stylesheets:
yu yong
Ranch Hand

Joined: Mar 09, 2008
Posts: 44
I have parsed the HTML. And get the tags(img, css) belong the html. But I parse the html is for getting the files(*.jpg, *.css) from the Web server. Can I get these files from the html response, without posting a download request again.
Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
The html response would contain only the links to the referred resources (like images, css files or js files etc). You need to establish new connection (or reuse the old one if KeepAlive is supported), to get those individual resources.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
If you run your original request in a browser and then view the source for the page you will see how the page references the files you want. The browser issues HTTP GETs for each file referenced from an HTML page. There can be many HTTP GETs issued by your browser to get referenced css and image files.
yu yong
Ranch Hand

Joined: Mar 09, 2008
Posts: 44
Thanks for Norm Radder and Santhosh Kumar, I have get the referred resources as your suggestion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get the temp file(css and image) from the response