So, after looking around a lot through the forums I'd first like to say thanks to everyone here. I've been hangin' out on the ranch for a little while and this is the first time I've actually felt like I needed to post. I always find an answer or am pointed in the right direction! (sorry for any improper use of jargon I'm not 100% on that stuff)
My problem is this: I have an app that works great on my local machine but not the server and the broken part is how I am accessing some image files.
I create jpg graphs in two different conditions:
When a file is fist inserted into the database
OR
If the file was already in the database prior to having graphs created on insertion
I save the graphs using a system call to a folder like this:
D:\data\IRdb\graphs\graph.jpg
and then update a database with these file paths.
So, on the server the path is not exactly the same but I need to figure out how to get to these with a
servlet link.
This is the code that works fine on my machine. I have a little icon for each graph in the table and
you should be able to hit the button to display the corresponding jpeg. When doing this on the server everything saves alright its just the html part with the href that will not work. I get a "resource cannot be found" error.
I first tried getServletContext().getRealPath() even though all the posts said not to (I just had to find out for myself) and of course it didn't work on the server (even though we DO use
tomcat on our server which should explode the files but I've moved on from there anyways).
I tried making something similar to Ben Souther's SimpleServlet example also but I ended up with the browser trying to save an image rather than have it pop up in the window.
I think that I probably need to use getResource() or getRescourceAsStream() in order to access my files.
When I try something like:
getServletContext().getResource("/") will return something but ONLY if i have the files in the WEB-INF/graphs directory in eclipse(I made another directory after frustration with the one on the D drive, I can't really get either to work anyways). This is no good because in some cases the picture doesn't even exist so I really need the directory rather than a file link.
getServletContext().getResourceAsStream("/WEB-INF") is really the only thing that doesn't turn out null but right now doesn't help because that is not where my files are. I am pretty sure this is what I somehow need to use but I am iffy on things like using InputStream and what classpath is. Otherwise I have been getting null return's for filepath strings i have been giving this function.
So that is what I know. If there was something I was unclear about or left out please let me know. I appreciate any help. I thought this was going to be an easy problem but have been banging my head off of walls for days.
[ April 02, 2007: Message edited by: Jenny Brook ]
[ April 02, 2007: Message edited by: Jenny Brook ]