• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image path problem

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Satish SN
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!