Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in reading csv file

 
pramodh somashekara
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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?
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic