Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Path Showing Tomcat Folder  RSS feed

 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently working on a project where I have to open an excel file for reading the contents on it.
I am using the POI package for reading Excel file and the File type for input. My servlet code goes as follows:




If I have the excel file (test1.xls) in my D: drive, once selected, the servlet takes the path of tomcat folder instead of taking D:/test1.xls.

It takes the path:

C:\Program Files (x86)\Apache Software Foundation\Apache Tomcat 7.0.27\bin\testing2.xls

INSTEAD OF TAKING

D:\test1.xls


Please help with a solution
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65764
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're going about it all wrong. You can't use normal Java file I/O to read a file on the client from code running on the server.

Please see the ServletsFaq and JspFaq for information on file uploading. You need to use HTTP, not file I/O.
 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You're going about it all wrong. You can't use normal Java file I/O to read a file on the client from code running on the server.

Please see the ServletsFaq and JspFaq for information on file uploading. You need to use HTTP, not file I/O.



Can you please help me with the code ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65764
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this FAQ entry. Depending on what library you choose to use, sample code is available at the respective site.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!