I have been following http://balusc.blogspot.in/2007/07/fileservlet.html but couldn't get it right with my code as i am not understanding much of it ...
filePath = request.getServletContext().getRealPath("")+File.separator+"images"+File.separator+"photo.jpg";
System.out.println(filePath);
// Get requested file by path info.
String requestedFile = request.getPathInfo();
System.out.println(requestedFile);
// Check if file is actually supplied to the request URI.
if (requestedFile == null) {
// Do your thing if the file is not supplied to the request URI.
// Throw an exception, or send 404, or show default/warning page, or just ignore it.
response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
System.out.println("terminates");
return;
}
what i get out of this is the program terminates here as the requestedFile is null all the time... can anyone help me go through the code.... Any Help will be appreciated !!! Thanks in advance !!!