<%@ page import="java.util.*,java.io.*"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+":\\\\"+request.getServerName()+":"+request.getServerPort()+path+"/"; out.println("Hi I am " + (String) path + "basePath = " + basePath ); //read the file name. ; File f=new File(getServletContext().getRealPath("turbowin_jws.jnlp")); String filenm = f.getAbsolutePath(); System.out.println(filenm); //set the content type(can be excel/word/powerpoint etc..) response.setContentType ("application/jnlp"); //set the header and also the Name by which user will be prompted to save response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\""); //get the file name //String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length()); //OPen an input stream to the file and post the file contents thru the //servlet output stream to the client m/c InputStream in = new FileInputStream(f.getAbsolutePath()); ServletOutputStream outs = response.getOutputStream(); int bit = 256; int i = 0; try { while ((bit) >= 0) { bit = in.read(); outs.write(bit); } } catch (IOException ioe) { ioe.printStackTrace(System.out); } outs.flush(); outs.close(); in.close(); %>