I'm studying Servlets/JSP using famous HeadFirst book and now in the chapter about Authentication. The problem is that I cannot login to my web app. I dont know why. I use FORM authentication method and I have created the login form. But when I enter username and password nothing going on. It just redirects me to the error login page. I am using the login and password from tomcat-users.xml:
Exactly the same situation was when I was trying to use BASIC authentication method, except that it was not redirecting me to error page, but showing password dialog again. What should I do to fix this? I have forgotten to implement something, I guess....
Hi, Since you have added <transport-guarantee> as CONFIDENTIAL, after login page container will redirect to an https page. If you haven't configured https in tomcat, it may redirect to login-error page. Please comment the <user-data-constraint> and see if it works!
I am using NetBeans IDE under which my tomcat runs. It turned out that there is a SECOND tomcat-users.xml file located in my documents/netbeans/... folder. And it really works. I have added my users and roles to that file and now BASIC authentication WORKS! But FORM authentication still redirects me to the error page
I try to reach MYAPPNAME/newform.html
Have you tried accessing the login page directly like:
Is that possible?
posted 10 years ago
yes this is possible. Actually reaching login page never was a problem, but still I cannot login using FORM authentication method.
May be the reason is Netbeans. It has its own account called ide and probably user is logged in automatically while using NetBeans. What usually happens when the user that is logged in tries to log in second time via login form?
What usually happens when the user that is logged in tries to log in second time via login form?
Nothing, a user only has to login once.
Does netbeans have an integrated browser? Otherwise try accessing the protected URL via another browser (different user, so should give you the login page). Or maybe netbeans hasn't implemented the FORM authentication... try tomcat as Rajeev was suggesting.
posted 10 years ago
actually I am using tomcat, as far as I understand netbeans is just an interface.
OK, I will try to deploy application on server though I was never doing this.. Now I have started the server without Netbeans, and copied my build folder from my documents to webapps. Now I can open every html form in my application, it looks like tomcat is not using my web.xml file. It is set properly: in the webapps/myapp/WEB-INF. What should I do after coping my build files to server webapp folder to deploy my application manually? At the moment my web.xml is out of the game.
Guys, thank you all for the assistance. The problem was in the loginform file which had different quotas inside because of copy-pasting from the book. I often meet this type of error, I should have been more concentrated. Now I will proceed with the last chapter of the book. Thanks!
The only thing that kept the leeches off of me was this tiny ad: