• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regd. downloading from jsp

 
Balasubramani Dharmalingam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to download a file using jsp like ,

<%

response.setContentType( "application/download");
response.setHeader("Content-Disposition", "attachment;filename=bala.txt");
out.print( "a," ) ;
out.print( "b," ) ;
out.print( "c" ) ;


%>
I am getting the file with "a,b,c" and two blank lines at the beginning of file. I should not get any blank lines.
When i tried the same with servlet, i am not getting any blank lines.Its is perfectly working.
What is the wrong with this code and why i am getting those blank lines ....?


Thanks in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP engine is probably adding the extra white spaces.

The intent for JSP is to create HTML formatted text.
In HTML white space is ignored and is unimportant.

If you need to output text in a specific format (with complete control) or if you want to stream binary data, you'd be much better off doing it with a servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!