aspose file tools*
The moose likes JSP and the fly likes downloaded file not written properly(File content written from 10th line why) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "downloaded file not written properly(File content written from 10th line why)" Watch "downloaded file not written properly(File content written from 10th line why)" New topic
Author

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

rajareddya reddy
Ranch Hand

Joined: Jul 23, 2011
Posts: 49
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

Joined: Jan 10, 2002
Posts: 61237
    
  66

Step 1: Move the code out of a JSP and into a Java servlet. Then we can take it from there.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

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

Joined: Oct 27, 2005
Posts: 19697
    
  20

In this case, lines 1-7 all add one line break before any binary data is written to the response.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

Please read this article to find out why using a JSP for this purpose is a big FAIL.
rajareddya reddy
Ranch Hand

Joined: Jul 23, 2011
Posts: 49
Thanks for all for your replies.
I tried the same code with servlet . now its working fine.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

Using the right tool for the job frequently yields better results.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: downloaded file not written properly(File content written from 10th line why)