Basic Authentication
843811Apr 14 2004 — edited Apr 2 2007I am trying to pass the username and password to a URL protected using basic authentication programatically.
I have a JSP that has a valid username and password. I construct the Authorization header and redirect to the protected URL as follows :
BASE64Encoder encoder = new BASE64Encoder();
String str = "admin:welcome"; // username and password
String encodedStr = encoder.encodeBuffer(str.getBytes());
response.setHeader("Authorization","Basic "+encodedStr);
String url = "http://incq044b.idc..com:80"; // protected url
response.sendRedirect(url);
But it does not redirect me to the protected page. Instead, it gives a Page not found error.
Has anybody got this to work.
Thanks for help
Chan