• Post Reply Bookmark Topic Watch Topic
  • New Topic

downloading txt file through jsp some extra lines(whitespaces) added in downloaded file

 
subodh varshney
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PrintWriter out1 = response.getWriter();
response.setContentType("application/octet-stream");
response.addDateHeader("Expires", 1);
response.setHeader("Content-Disposition","attachment;filename="+pagename);
out1.write(contents.substring(0,contents.length()).trim());
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do not use JSP for this. Writing raw Java code in a JSP is a very bad practice. Raw Java code belongs in Java classes. Use a Servlet class for this and your problem will automagically disappear. Use JSP for presentation only, with taglibs and EL only, no scriptlets.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!