I sometimes have a problem with the ContextRoot value in a session. For some unknown reason, every once in a while the ContextRoot in the session is deleted/wiped out. In one of my servlets, I am sending an image file from a BLOB in an oracle database to an applet in a jsp to be displayed. The proble m is that if a record does not have a corresponding image, the servlet sends a n image saying something like "No Image Available". This works most of the time, but when it fails I get a null pointer exception. Here is the method where the problem is occurring:
I have written and tested this in a Windows 2000 Environment, before it is deployed to a Unix based Web Server so I don't think hard coding the file directory will work.
We were using the ContextRoot from the session to give the directory for the no image file. The directory we stored it in was the images folder of webroot. I have tried the contextPath from the request and it does not give the correct path, unless I have missed something, which wouldn't be the first time.