• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple path question  RSS feed

 
Dave Berkheimer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've written a class that handles some image manipulation that I need done and I'm having issues accessing the image that I wish to manipulate via a relative path to the image.

The image that I wish to manipulate is in the root directory of the application... lets say it's name is image.jpg

The class is in the following directory... WEB-INF/com/xxx/utils/

I have no problems getting to the image if I use an explicit complete path like "c:\\testdir\\image.jpg"

I know this is fairly easy, I'm just having issues getting to it.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66148
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the proper context-relative addressing for the image resource?

See the JSP FAQ if not.
 
Dave Berkheimer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Are you using the proper context-relative addressing for the image resource?


I believe so.... the path that I'm using is "../../../../image.jpg". This should get me to the location of the image file. That's assuming or course that you can use relative paths for new File objects. Working with Files is a bit new to me....

Thanks
Dave
 
Dave Berkheimer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

Thanks for your help...

I decided to go with the getContextPath() function and take it from there. Works like a charm.

Dave B
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66148
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Berkheimer wrote:I decided to go with the getContextPath() function and take it from there. Works like a charm.

Good call. The page-relative addressing with "../" is a recipe for disaster.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!