Hi,
What I am trying to do is pop up a username/password box to authenticate, and if the authentication fails, then redirect to another page. I am happy with the authentication, it works fine, but I have no idea how to intercept the 401 screen that occurs if authentication fails. This is what I have:
response.setHeader("Pragma", "no-cache"
response.setHeader("Cache-Control", "no-cache, must-revalidate"
String auth = request.getHeader("Authorization"
if (auth == null) {
send401(response);
}
else
{
blah blah
}
void send401(HttpServletResponse response) throws IOException{
response.setHeader(" "Basic realm=\"(Customer Reporting)\""
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Login error, password is incorrect. Your account may have been locked."
}
If I step through this code, it failes the auth == null and goes straight to send401. It only pops up the username/password prompting box when the response.sendError is called, if it fails it drops to an ugly 401 screen, I want to forward it to another URL. Is there any way of intercepting this? Sorry if this isn't very clear, but I'm not really sure how this stuff works.
Thanks, Brett.
What I am trying to do is pop up a username/password box to authenticate, and if the authentication fails, then redirect to another page. I am happy with the authentication, it works fine, but I have no idea how to intercept the 401 screen that occurs if authentication fails. This is what I have:
response.setHeader("Pragma", "no-cache"
response.setHeader("Cache-Control", "no-cache, must-revalidate"
String auth = request.getHeader("Authorization"
if (auth == null) {
send401(response);
}
else
{
blah blah
}
void send401(HttpServletResponse response) throws IOException{
response.setHeader(" "Basic realm=\"(Customer Reporting)\""
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Login error, password is incorrect. Your account may have been locked."
}
If I step through this code, it failes the auth == null and goes straight to send401. It only pops up the username/password prompting box when the response.sendError is called, if it fails it drops to an ugly 401 screen, I want to forward it to another URL. Is there any way of intercepting this? Sorry if this isn't very clear, but I'm not really sure how this stuff works.
Thanks, Brett.