Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
yu yong
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Norm Radder and Santhosh Kumar, I have get the referred resources as your suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic