Вы пробовали Window.open(ServletUrl, "_parent", "location=no")
?
И попробуйте установить ContentType в ответ на "application / exe"
Это предложит пользователю сохранить или запустить.
Код сервлета:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String filename = URLDecoder.decode(request.getPathInfo(), "UTF-8");
File file = new File("/path/to/files", filename);
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.setHeader("Content-Length", file.length());
BufferedInputStream input = null;
BufferedOutputStream output = null;
try {
input = new BufferedInputStream(new FileInputStream(file));
output = new BufferedOutputStream(response.getOutputStream());
byte[] buffer = new byte[8192];
for (int length = 0; (length = input.read(buffer)) > 0;) {
output.write(buffer, 0, length);
}
} finally {
if (output != null) try { output.close(); } catch (IOException ignore) {}
if (input != null) try { input.close(); } catch (IOException ignore) {}
}
}