This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Upload an HTML file along with images contained in that page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Upload an HTML file along with images contained in that page" Watch "Upload an HTML file along with images contained in that page" New topic
Author

Upload an HTML file along with images contained in that page

Muhammed Akhtar Hossain
Greenhorn

Joined: Jun 11, 2003
Posts: 2
Hi/
I would like to copy an html file to a particular destination and also all the images contained in that file. Can u please help me how can I find the image names(paths) from the html page in run time ?


Javed/
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Thats going to be a bit of programming, but basically you will have to find the IMG or img tags, extract the SRC or src attribute and figure out what that means in terms of a URL. Keeping in mind that an image source might be an absolute or a relative URL - also that there may be a BASE tag in the page that specifies a base different from the one the page lives at.
Once you figure out the real URL you can open a URLConnection, get an InputStream, and read the binary image data.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Upload an HTML file along with images contained in that page
 
Similar Threads
JSP INCLUDE
How to update the help menu?
Servlets, HTML and GIFs
JSP + Images
Image problem in Jasper reports