Server: tomcat.
I created a Servlet to call JAVA program to process CSV file.
The code new ToJSON().main(files) will process the csv files to json.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String [] files = request.getParameter("files").split(",");
System.out.println(String.join(",", files));
new ToJSON().main(files);
////call the java program to convert CSV files to json then sent the file name or the contain back.
response.getWriter().append("data.json");
}
SEVERE: Servlet.service() for servlet [charting.servlet.ChartingServlet] in context with path [/Charting] threw exception
java.io.FileNotFoundException: BankFileLine.csv (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at format.LoadCSVFile.iterable(LoadCSVFile.java:60)
at format.LoadCSVFile.getMaxLength(LoadCSVFile.java:44)
at format.LoadCSVFile.<init>(LoadCSVFile.java:26)
at toJSON.ToJSON.main(ToJSON.java:26)
But I kept getting filenotfoundexception. I tried to put the files into WebContent and src. none of them worked. I tried to adding the path:localhost:8080/ChartingServlet/filename, still did not work.
Here is the directories Here is the directories of the project files
My question is where I should put the files?