servlet sending images to browser
servlet sending images to browser
(OP)
I want to send my webpage from a servlet, that dynamically creates the HTML-page from a tmeplate. Of course there will be pictures on the website. All book examples show how to handle one file if you know that you want to send THIS ONE file.
Sorry for the question but none of my books explains the MECHANISM!
I couldn't see any pictures - obviously they are not send.
The HTML page itself works fine. From the servlet do I have to send every single file (img, css) one by one?
How about the CSS file and it's images ?
Do I really have to send every single image "by hand", having to control even all CSS background images and my app's images by using getRealPath and the filename?
Where do I send them to?
Do I have to scan my HTML and my CSS for file names to be able to put my output together DYNAMICALLY?
By the way - I have no idea what getRealPath() is doing - I definitely don't get the path. ( .../WEB-INF/classes/ )
Please explain the mechanism shortly to me. I always thought ressources that are not there yet would be REQUESTED by the browser....
Thank you in advance
Andreas
Sorry for the question but none of my books explains the MECHANISM!
I couldn't see any pictures - obviously they are not send.
The HTML page itself works fine. From the servlet do I have to send every single file (img, css) one by one?
How about the CSS file and it's images ?
Do I really have to send every single image "by hand", having to control even all CSS background images and my app's images by using getRealPath and the filename?
Where do I send them to?
Do I have to scan my HTML and my CSS for file names to be able to put my output together DYNAMICALLY?
By the way - I have no idea what getRealPath() is doing - I definitely don't get the path. ( .../WEB-INF/classes/ )
Please explain the mechanism shortly to me. I always thought ressources that are not there yet would be REQUESTED by the browser....
Thank you in advance
Andreas
RE: servlet sending images to browser
-----------------------------------------
I cannot be bought. Find leasing information at http://www.joshaxtell.com/
RE: servlet sending images to browser
Maybe I have to ask more clearly:
I send a page (HTML only).
It is presented by the browser.
All images (NOT EXPLICITLY SEND by my servlet) and all CSS information from the css file
( /css/xyz.css, NOT EXPLICITLY SEND by my servlet ) are ignored/missing.
I don't want to send what I don't have to send. I dont't understand why my webpage is uncomplete.
My understanding up to now is that FILES that are not there will be REQUESTED by the user's browser - so I don't have to take action.
But this doesn't work. That's why I asked to explain the MECHANISM - servlets may be different from HTML/PHP etc. - I don't know.
It should be no difference that I am working in an offline environment (TOMCAT) - right?
RE: servlet sending images to browser
-----------------------------------------
I cannot be bought. Find leasing information at http://www.joshaxtell.com/
RE: servlet sending images to browser
If I use a computer to run Tomcat server and I cannot connect to Internet with this computer, there can be a chance of problem appearance for image file.
If you specify image path in html by http://www.yahoo.com/image1.jpg, no Internet connection will create broken image problem. (Because you refer image to outside server and you will require Internet connection)
if you specify image path in html by /images/image1.jpg, you are referring image on your server(that contain your html)
The general idea is the same as jaxtell said.