• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How to access local files on Tomcat server?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to access xml files from my computer, parse through them and extract useful info, then push this info to a webpage and upload on tomcat server. It all works fine until the last step, and tomcat gives me this error




That directory exists and I can print what I need to on Eclipse, but how can I access it differently to where Tomcat can use it? Right now I am using



to access the file, with the path being sent through the fileName parameter.
 
Rancher
Posts: 4117
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where does the filename come from?

As an aside, I notice you seem to be doing a lot of your work in a JSP page.
That work should really be in a servlet.
 
Spalding Latham
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Where does the filename come from?

As an aside, I notice you seem to be doing a lot of your work in a JSP page.
That work should really be in a servlet.



I need to parse through 3 different files, so I have my getXML(String fileName) and I call that 3 times with each different file. Also this is the entirety of my JSP file:



All it does is call the getFormattedMetrics() method, my DataAccessor class is doing all of the work.
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done raw JSP pages in a while, but I think that the more appropriate way to do that is via a useBean element.

As for the "File Not Found", double-check your path and MAKE SURE that there aren't any differences between uppercase and lowercase between the name in the error message and the actual pathname in the file system. Windows is not case-sensitive, but Java is.

Also, Tomcat does have to have file read access rights to that file. When running Tomcat from Eclipse, that generally means that the userid that Eclipse is running under has to have those rights, since Tomcat would generally be running under the same userid as Eclipse.
 
Spalding Latham
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:I haven't done raw JSP pages in a while, but I think that the more appropriate way to do that is via a useBean element.

As for the "File Not Found", double-check your path and MAKE SURE that there aren't any differences between uppercase and lowercase between the name in the error message and the actual pathname in the file system. Windows is not case-sensitive, but Java is.

Also, Tomcat does have to have file read access rights to that file. When running Tomcat from Eclipse, that generally means that the userid that Eclipse is running under has to have those rights, since Tomcat would generally be running under the same userid as Eclipse.



File names are correct, just double checked. As for the permissions, where would I go to look if Tomcat has access to read rights?
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Spalding Latham wrote:File names are correct, just double checked. As for the permissions, where would I go to look if Tomcat has access to read rights?



It looks like you're using Windows, so you'd go to File Explorer and navigate to the file. Right-click on the file, select "Properties", open the "Security" tab to see the file's permissions.
 
Dave Tolls
Rancher
Posts: 4117
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you running Tomcat?
Is it through Eclipse, or is it a service, or a standalone?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!