• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in reading csv file

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have servlet under the path "java source/com/sample/search/search1/MyServlet.java" file and my csv file in "Web Content/csv/mycsv.csv"

When I tried to read the csv file from my servlet by giving path as ".../Web Content/csv/mycsv.csv", I am getting file not found exception.

Can you explain how to give correct path from servlet to my csv file?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a ServletContext method that returns the absolute or real path given a relative path.

You can use myServlet.getServletContext() to get to the ServletContext

Check the API for the exact method.

Hope this is at least a pointer in the right direction.
 
reply
    Bookmark Topic Watch Topic
  • New Topic