I have Netbeans 7.1.2 running and I am trying to access some text files within a servlet:
package com.optimizations.cutting;
@WebServlet(name = "Servlet", urlPatterns = {"/Servlet"})
public class Servlet extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    System.out.println("in servlet "+System.currentTimeMillis());
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        DataManager dm = new DataManager();
        SheetInfo si = dm.loadSheetInfoCSV("sheetInfo.csv");
        ArrayList<Piece> pieces = dm.loadPiecesCSV("res/pieces4.csv");
....
I have placed the sheetInfo.csv and the pieces4.csv files everywhere i could think of, trying to acces them with a backslash ahead ( /sheetInfo.csv or /res/pieces4.csv )
when i say "everywhere i could think of" i mean : current directory (source packages), next to Servlet.java and all the other files I created (including DataManager.java which uses it). I also did the "Add folder" in the Properties window->Sources->Package Folder. (added 2 folders, just to make sure ). So my dear files are in 3 places all at once:
- src/java/com/optimizations/cuttingnext to- Servlet.javaand- DataManager.java
- src/java/res
- src/resourcesbut i stll get the- SEVERE: java.io.FileNotFoundException: resources/pieces4.csv (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:97) at java.io.FileReader.<init>(FileReader.java:58) at com.optimizations.cutting.DataManager.loadPiecesCSV(DataManager.java:98)`
I have also restarted the server (Glassfish 3.1.2)
(maybe this seems silly but I also need to know where and how should i place my files so they can be accessed from both the client and the server - my servlet will create some images(.jpg) and store them (where?) and will send the filenames back to a .jsp which will then show them in a colorbox)
thanks in advance.
edit
added some more lines of the error and the call in DataManager.java:
public SheetInfo loadSheetInfoCSV(String filename){
    ....
    br = new BufferedReader( new FileReader(filename));
    String strLine = "";            
    //read comma separated file first line
    if ((strLine = br.readLine()) != null)
    ....
 
    