Click here to Skip to main content
11,805,604 members (62,513 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Javascript Java JSP
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?
Posted 5-Apr-13 20:50pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100