I am trying to upload a binary image file to do some processing inside my server side Java code. Currently, I put my image in a package where my executable class exists and the caller:
Image img = Image.getInstance(this.getClass().getResource("logo.png"));
This works fine when I launch Tomcat in my exploded window in exploded war mode, but when I deploy a server running Tomcat where it does not explode war files, the getResource call returns null.
I also tried moving the image to my root context and accessing it like this:
Image img = Image.getInstance(this.getClass().getResource("/../../logo.png"));
Again, this works in my development window, but not when I deploy it elsewhere.
Is there a better way to access this file? What am I doing wrong?
Thank!!
source
share