you can access resources from within WEB-INF
folder just using /WEB-INF/test.xml
from within your application (jsp - servlet).
<!%@ taglib uri="/WEB-INF/tiles-jsp.tld" prefix="tiles" %>
If you want to make it available to a web user then it CANNOT be accessed directly. For a user to access it directly, there must be some sort of interface that will expose the file from the WEB-INF folder (ex. jsp that reads the file /WEB-INF/test.xml and output's it to the jsp/servlet)
UPDATE
To read a file using a Servlet use this:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
StringBuffer strContent = new StringBuffer("");
int ch;
PrintWriter out = response.getWriter();
try {
String path = getServletContext().getRealPath("/WEB-INF/newfile.xml");
File file = new File(path);
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
while ((ch = fin.read()) != -1) {
strContent.append((char) ch);
}
fin.close();
} catch (FileNotFoundException e) {
System.out.println("File " + file.getAbsolutePath()
+ " could not found");
} catch (IOException ioe) {
System.out.println("Exception while reading the file" + ioe);
}
System.out.println("File contents :");
System.out.println(strContent);
} finally {
out.close();
}
}
This will read a file named newfile.xml from WEB-INF
and will output its contents to the console. The output will be something like:
File contents :
< a >
< b >xxxx< /b >
< /a >