• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Not able to access Network Drive

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am running Tomcat 6 in Windows Server 2003 operating system. I have a problem accessing network shared drives from within my servlets and JSP-pages.

For instance, if "S" is a mapped drive pointing to something like a
shared network drive "\\shared_server\shared_drive", then this scriplet
returns
"false":

<%
java.io.File file = new java.io.File("S:/test.txt");
boolean exists = file.exists();
out.print("exists: " + exists);
%>

The file "test.txt" does exist, but Tomcat does not see the shared
drive.

Please help.

Thanks,

Prabhat
 
Sheriff
Posts: 24632
56
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presumably Tomcat is running as a Windows service. Windows services don't have any network drives mapped.

You could probably deal with that by using the UNC path for the share instead of the version of the path which assumes that a drive has been mapped. But if you do that, make sure the Tomcat service is running as a user which has access to that share. Services which are logged on as the local system account don't have access to UNC paths either.
 
Prabhat Kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.

How should i user UNC path (sorry, i am bit novice) and how should i get assured that my tomcat is running using which user account?

Prabhat
 
Paul Clapham
Sheriff
Posts: 24632
56
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prabhat Kumar wrote:How should i user UNC path (sorry, i am bit novice) and how should i get assured that my tomcat is running using which user account?



The UNC path is just like what you posted as an example: \\shared_server\shared_drive

To configure a service to log on as a specific user, go to the Services in the Control Panel (via Administrative Tools). Right-click on the service, select Properties and go to the Log On tab. Enter the user ID and its password.
 
Prabhat Kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the user as you suggested. It worked. Thanks very much.
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!