Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

File Path Showing Tomcat Folder

 
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: 65542
110
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: 65542
110
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.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!