| Author |
Image path problem
|
Chetan Parekh
Ranch Hand
Joined: Sep 16, 2004
Posts: 3636
|
|
We have an application in JSP + Tomcat. We have another desktop application on the same PC. We have common images that has used in both applications, hence we made a common folder c:\images and put all images there. Desktop application is already using images from that folder, and in web application, we have written This is working fine if we have Windows OS on the server. But we deploy application in Linux, and give execute following code It gives error. It looks for var/images/ folder in tomcat_home/webapps folder.
|
My blood is tested +ve for Java.
|
 |
Satish SN
Ranch Hand
Joined: Apr 19, 2005
Posts: 70
|
|
Hi Chetan, I feel in windows case you are giving the absolute path stating the drive and the folder structure in linux scenario i feel u need to put a slash before the var folder other wise the linux will treat the same as relative path from the tomcat. i think the best practice i would suggest for mentioning the images should be from the web application context path so that there is no need to modify every time for the image paths
|
Satish SN<br />SCJP 1.4 & SCWCD 1.4
|
 |
Sravan Kumar
Ranch Hand
Joined: Sep 11, 2005
Posts: 121
|
|
Your images are a part of your web-app, so put them under the context root, say, in a folder called images. You can refer to them in your servlets or JSP as "/images/pic1.gif". Do not refer to the images as physical files as it will be inconvenient to deploy your webapp in some other server at a later date. The bottomline: Treat images are web-app resources, not files.
|
keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
|
 |
Chetan Parekh
Ranch Hand
Joined: Sep 16, 2004
Posts: 3636
|
|
Originally posted by Sravan Kumar: Your images are a part of your web-app, so put them under the context root, say, in a folder called images. You can refer to them in your servlets or JSP as "/images/pic1.gif". Do not refer to the images as physical files as it will be inconvenient to deploy your webapp in some other server at a later date. The bottomline: Treat images are web-app resources, not files.
My problem is that they are not part of my context.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
How much space are you saving by not duplicating the images and keeping a copy in the webapp? If maintenance is the issue, create a build script using Ant or Maven and have it gather the images for you when you package the app.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Chetan Parekh
Ranch Hand
Joined: Sep 16, 2004
Posts: 3636
|
|
Originally posted by Ben Souther: How much space are you saving by not duplicating the images and keeping a copy in the webapp? If maintenance is the issue, create a build script using Ant or Maven and have it gather the images for you when you package the app.
Well I have already suggested this solution, but my PM is not agree to this.
|
 |
Sravan Kumar
Ranch Hand
Joined: Sep 11, 2005
Posts: 121
|
|
Well, now I think that's more of a management issue than technical. Chetan, you can probably send him a link to this forum. Are you telling us your PM wants to refer to images as physical files?
|
 |
 |
|
|
subject: Image path problem
|
|
|