I have a maven parent project--->vehicle. under that there a two projects: car, bike. under car project--> src/main/resource folder there is a file abc.txt. In bike project i have a servlet class. From here i am downloading the abc.txt file. So for the code:
Strinf filePath = "";
what should be the value i need to pass to the filePath variable?
servlet complete code of doGet method :
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String filename = "abc.txt";
String filepath = "";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=\""
+ filename + "\"");
// use inline if you want to view the content in browser, helpful for
// pdf file
// response.setHeader("Content-Disposition","inline; filename=\"" +
// filename + "\"");
FileInputStream fileInputStream = new FileInputStream(filepath
+ filename);
int i;
while ((i = fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.close();
}
}