Click here to Skip to main content
15,794,593 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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


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


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 logs.

For my code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="*"  %> 
<!DOCTYPE html>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
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(); 

try {    
    PrintWriter pw = new PrintWriter(new FileOutputStream("c:/jdk-6u20-windows-i586.exe"));// save file 
} catch(IOException e) { 

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?

1 solution

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
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900