2 Replies Latest reply: Feb 11, 2011 4:29 PM by meatwad RSS

    Accessing local files through a servlet in glassfish

    meatwad
      I need a way to access a configuration file from a servlet but keep it hidden from the end user/client. This is the method I have previously used in Oracle App server:
      filepath = getServletContext().getResource("/cfgfile").getPath();
      InputStream is = getClass().getResourceAsStream(filepath);
      This worked. However in glassfish this technique returns a true url to a file in the document root. That would be ok but it allows the user to view it from a web browser as well and I want to prevent that. Is there a way I can do this?