This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Tomcat and the fly likes File i/o from Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File i/o from Tomcat" Watch "File i/o from Tomcat" New topic

File i/o from Tomcat

Gary Pierce

Joined: Apr 03, 2006
Posts: 3
A servlet, with the help of POJOs, tries to see if a file exists at different locations in the network. It goes thru' a set of locations one by one. When executed, for some locations, it reports that the file does not exist, even though it does actually.
Here is the simplified version of the code. The same code when executed outside the container i.e.,from a main() call, it works fine.
Any suggestions?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

How are you running Tomcat?
If you are running it as a Windows service, check to see if the user under which the service runs has network permissions.

From the services window, you can change which user the service runs under.
This solved the same problem for me.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Gary Pierce

Joined: Apr 03, 2006
Posts: 3
Thanks Ben.
Yes, Tomcat runs as a Windows service, with my network user id account. With the same id, like I said, this works fine when run outside the container as a plain Java program with main() method.

I agree. Here's the link:
subject: File i/o from Tomcat
It's not a secret anymore!