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.
Best what you can do is to use java.net.URLConnection to get an inputstream of the specified URL.
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.