Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to ignore space ?

Posted on 2007-11-23
5
Medium Priority
?
1,908 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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