
Hi deepak;
i am posting some peace of code. and i need to call jsp varable <%=f%> through servlet so that it can call the downlode.jsp page.
String f = "C:/temp/View HR LeaveBalance2.txt";
FileWriter writer = new FileWriter(f, true);
BufferedWriter bw = new BufferedWriter(writer);
while (rs.next()) {
String st1 = rs.getString(1);
String st2 = rs.getString(2);
String st3 = rs.getString(3);
String st4 = rs.getString(4);
bw.write(st1 + " " + st2 + " " + st3 + " " + st4);
bw.newLine();
bw.newLine();
out.println(st1);
out.println(st2);
out.println(st3);
out.println(st4);
and i given a hyperlink to call this downlode page like
out.println("Download document");
when i click on this hyper link it gives error i want only one downlode.jsp and it will save all the text.file if i put like code given it will work fine but [request.getParameter("ff")]not working can u give me any suggetion for that
<% String file = "C:/temp/A1.txt"; //request.getParameter("ff");
File f = new File(file);
String filename = f.getName();
String type = getMimeType("file:" + file);
response.setContentType(type);
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1, f.getName().length());
InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.