This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Below is my Web application structure ( i have shown the only the required files/ folders). Myapp,images,WEB-INF are at same level web Myapp start.jsp images logo.gif WEB-INF web.xml
my start.jsp looks like this, where iam trying to display the logo image from images folder <% // do nothing other than showing the image %> <html> <head></head> <body> <img src="/images/logo.gif"> </body> </html>
The above start.jsp displays the image when i deploy this application as default ( i access it as http://localhost/). The image path ( when i check thru Image properties in IE ) will be http://localhost/images/logo.gif. But the problem comes when i give a name to the web application, say i give it as "mywebapplication" ( i access it as http://localhost/myapplication), In the case the image wont be shown. Still its path will be http://localhost/images/logo.gif, but actually it should have been http://localhost/mywebapplication/images/logo.gif. I want the image to be shown, but once it is deployed i dont want my JSP code to be changed whether it is deployed as default webapp or deployed with some contextName ( like mywebapplication or ourwebapplication etc.). Is my <img> tag in the above JSP is wrong or i need to do some configuration in web.xml. Any help is appreciated Hari
It's because your image is linked like this: <img src="/images/logo.gif"> the "/" in the beginning tells it to go to the root of the server. So if you keep it as <img src="images/logo.gif"> It will always be relative to where you are -- and in the case of your /mywebapplication it will look for file at /mywebapplication/images/logo.gif