hi all,
i am using the below code to open a n application by specifying the file path
response.setHeader("Content-Disposition", "attachment; filename="+ java.net.URLEncoder.encode(filePath) +"");
but while opening the application the path changed as D%3A%2FPrepress%2F5_Production%2FJournals%2FBalaban%2FPI10000044%2FBban_MWMS_100005%2FData%2Fset+header[3] with special characters because of the filepath changed i cant apple to use the save button.
i think the url encoder is changed the path.
pls help for my problem.

Recommended Answers

All 4 Replies

Well, of course it is. What do you think the URLEncoder does?

You don't need to (and shouldn't) provide a path in that content header, anyway. Rather you should provide the filename only.

And you do realise, that the client (i.e. the machine from which the browser is running from) is not accessing the original file from the server, but rather a "copy" that is sent to it and placed in cache, right?

hi masijade,
actually i am fetching the file name from the database so the filename is changing dynamically.
so i cant able to give the filename directly.
if u have any solution for this problem na pls help me yaar
for ex.D:/Prepress/5_Production/Journals/Balaban/PI10000044/Bban_MWMS_100005/set header.doc this is the original filepath i am fetching this from database.
advance thanks

Create a File object from the given name and then do getName() (which a quick look at the APIs would tell you).

The concept remains the same, however. And, as I already said, don't use the URLEncoder (what do you think this does?).

k i will try and tell the action... anyhow thanks for ur kind response.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.