aspose file tools
The moose likes Servlets and the fly likes Redirection to a basic-authenticated page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirection to a basic-authenticated page" Watch "Redirection to a basic-authenticated page" New topic

Redirection to a basic-authenticated page

David Salaete

Joined: Aug 27, 2008
Posts: 19

Hi all,
I have a servlet that has to redirect to a remote page (another domain, another machine) and this new page is protected under basic authentication (you know, floating window asking for user/pass)...
Well, I´ve no problem to do it, using URLConnection or Apache HttpConnection...
Then I take the response and I write it on the standard servlet output. Now I have the new remote page.

BUT my problem is that (logically) I stay in my servlet context (that means, navigator´s URL is http://mymachine:8080/myservlet ) so every link in the new remote page is not working (because they´re not absolute but relative, as expected).

Then I´m trying to do a kind of sendRedirect(), but I´m not able to put it to work. request.sendRedirect() is not working because the page is asking me again for user & pass.

I need to redirect the page (URL in navigator must be http://remotemachine:8080/whatever....) but having pass authentication.

I´ve tried:
- Ajax connection using a dinamically generated form: Ok for IE, not works in firefox (security reasons)
- Using request.setHeader(): Doesnt´work, I dunno why

¿How can I redirect to a page passing this authentication?

Thank you very much and forgive my bad English...!


There are 10 types of people: Those who understand binary code and those who don�t.
Have you tried LearnNowOnline?
subject: Redirection to a basic-authenticated page