• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

downloaded file not written properly(File content written from 10th line why)

 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My requirement is to get the file content from temporary file and then I am writing to one more file which I created and I need to download the same file. When I am executing the following code , I am able to download the file but I am seeing 10 lines with empty spaces. That means code is writing the conent in the new file from 10th line.Please corerct the code,why its writing content from 10th line in the new file.


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: Move the code out of a JSP and into a Java servlet. Then we can take it from there.
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Bear is right.

2. JSP generates blank lines everywhere and anywhere it can! that is the nature of the beast.

WP
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case, lines 1-7 all add one line break before any binary data is written to the response.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article to find out why using a JSP for this purpose is a big FAIL.
 
rajareddya reddy
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all for your replies.
I tried the same code with servlet . now its working fine.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the right tool for the job frequently yields better results.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic