| Author |
Two HttpServletResponse Responses?
|
Charles Swanson
Greenhorn
Joined: Nov 24, 2009
Posts: 9
|
|
How do I send two HttpServletResponse responses? I'm writing an app where I save a file to the user's PC and then redirect them to another page. I can save the file or redirect, but not do both. Here's my code:
If I leave it as-is, it will redirect to google without saving the file. If I comment out the redirect line, the file saves as it should.
Is there some way to make both work?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
|
You can only send one response.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Charles Swanson
Greenhorn
Joined: Nov 24, 2009
Posts: 9
|
|
I kinda figured as much. Thanks for the confirmation.
Any easy ways around this? Or will it just be a "fun" little problem solving mission for me?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
|
It's not clear exactly what you are trying to accomplish by redirecting to google. If you were redirecting to something within your own app, that'd be different.
|
 |
Charles Swanson
Greenhorn
Joined: Nov 24, 2009
Posts: 9
|
|
|
Sorry, I should have mentioned the google URL was just a filler. The actual app would redirect to another page within the site.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
Try not to do that. Using "filler" in this case, creates a completely different environment for the question.
Generally, things like this are accomplished by redirecting to the next page first, and having JavaScript on that page that initiates the request that performs the attachment download.
|
 |
Charles Swanson
Greenhorn
Joined: Nov 24, 2009
Posts: 9
|
|
Unfortunately, I'm unable to use JavaScript. The site this will be hosted on has a policy against using JavaScript (which has made the project more difficult than it should be... it's a longer story, but in the end I was told no JavaScript, so I went with that.)
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Well, you certainly aren't going to be able to do that without some Javascript somewhere. So I guess your project sponsors are just out of luck there.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
|
Ah yes, denying carpenters their saws.
|
 |
Charles Swanson
Greenhorn
Joined: Nov 24, 2009
Posts: 9
|
|
Bear Bibeault wrote:Ah yes, denying carpenters their saws.
Haha, exactly. It's actually been a semi-entertaining challenge to build this thing without any JavaScript. It's certainly created some large and ugly code though...
Thanks for the help guys... at least I won't waste too much time finding a non-existent answer.
|
 |
 |
|
|
subject: Two HttpServletResponse Responses?
|
|
|