通过JSP将EXE文件保存在客户端pc中 [英] Saving EXE file in client pc by JSP

查看:228
本文介绍了通过JSP将EXE文件保存在客户端pc中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个代码,用于将我的服务器端的exe文件保存到C:\驱动器中的客户端PC上。

但是,我收到的错误是这样的:



类型异常报告



留言



description服务器遇到内部错误(),导致无法完成此请求。



例外



java.lang.OutOfMemoryError:Java堆空间

note GlassFish Server开源版3.1.2.2日志中提供了异常的完整堆栈跟踪及其根本原因。




我的代码:

Hi, I have written a code to save an exe file from my server side to client''s pc in C:\ drive.
But, I am getting error as like this:

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.OutOfMemoryError: Java heap space
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.


For my code:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"  %> 
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <% 
String fileName=getServletContext().getRealPath("jdk-6u20-windows-i586.exe"); 

File f=new File(fileName); 

InputStream in = new FileInputStream(f); 

BufferedInputStream bin = new BufferedInputStream(in); 

DataInputStream din = new DataInputStream(bin); 
StringBuffer sb=new StringBuffer(); 
while(din.available()>0) 
    { 
    sb.append(din.readByte()); 
    } 

try {    
    PrintWriter pw = new PrintWriter(new FileOutputStream("c:/jdk-6u20-windows-i586.exe"));// save file 
    pw.println(sb.toString()); 
    pw.close(); 
} catch(IOException e) { 
   e.getMessage(); 
} 
          
in.close(); 
bin.close(); 
din.close(); 
%> 
    </body>
</html>



请帮我解决这个问题。如果我想添加一个进度条来显示下载文件的计数%,而不是我在代码中为此做的事情。你能帮助我兄弟吗?


Please help me to solve this problem. And if I want to add a progress bar to display count % for downloading file than what I have to do for this in my code. Can you help me brother?

推荐答案

没有热门浏览器可以访问客户的本地文件系统

在这种情况下你可以通过将其放在项目文件夹或GlassFish Server文件夹中来提供文件链接

或者您使用签名小程序
No Popular browser will give you access to Client''s local file system
In this case you can provide a link to file by putting it in your project folder or GlassFish Server folder
or else you case use a signed applet

这篇关于通过JSP将EXE文件保存在客户端pc中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆