?
Solved

How to ignore space ?

Posted on 2007-11-23
5
Medium Priority
?
1,911 Views
Last Modified: 2012-06-27
ServletOutputStream out = response.getOutputStream();
            response.setContentType("application/x-download");
            String rowid=(String)request.getParameter("id");
            String fileName=(String)request.getParameter("filename");
            response.setHeader("Content-Disposition", "attachment; filename=" + fileName); // fileName ="ABCD EFGH IJKL.xls"
            DownloadUtil dutil =new DownloadUtil();
            byte[] excelbyte=dutil.getFile(rowid);
            out.write(excelbyte);


            the downloaded file comes as ABCD without any extension.

            but if there were no spaces in the filename , the downloaded files comes with the filename as it was.

            so, how to ignore space in the filename ?
0
Comment
Question by:cofactor
  • 3
  • 2
5 Comments
 

Author Comment

by:cofactor
ID: 20338483
my filename will have spaces and i want them downloaded with the same name with spaces
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 600 total points
ID: 20338527
Try

response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
0
 

Author Closing Comment

by:cofactor
ID: 31410657
excellent grade
0
 

Author Comment

by:cofactor
ID: 20341862
excellent grade CHEJ.

that worked
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20342202
:-)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question