i want to create a servlet to recursively save the image in a webpage when given a starting point(the webpage url).
but my problem is how to save the images? what should i do with the image's url once i successfuly obtained it?
A servlet to save images from an external resource? Well, you normally don't use servlets for that, so I at highest assume that you want to execute this application logic using a servlet. It is at least in no way possible with the request and response objects you have in a servlet.
You will need to parse the HTML for <img> tags, extract the value of their source attribute, reconstruct full URLs from that, and then download the image from that URL. Be sure to handle relative as well as absolute URLs, and consider the effects of a <base href="..."/> tag.
Joined: Dec 26, 2008
thanks again for your reply.
how do i download the image ?
because my code is able to retrieve url already.. so i have all the urls of the images i want... but i dont know how to download them to my localhost..