It's not a secret anymore!*
The moose likes Tomcat and the fly likes tomcat authentication not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat authentication not working" Watch "tomcat authentication not working" New topic

tomcat authentication not working

hai sun

Joined: Sep 17, 2012
Posts: 2

Follow the Tomcat [tag:tomcat]'s tutorial for form-based authentication, I've tried it out in localhost.
My purpose is to protect /lvyouzaike/admin/*
I've mapped the domain name to $(TomcatPath)/webapps/lvyouzaike directory. I aim to let login.jsp shown when I type, suppose index.jsp is one of the files to be protected.
Next I post related files.

majority code of web.xml

context.xml under $(TomcatPath)/lvyouzaike/META-INF

related code of server.xml under $(TomcatPath)/conf

login.jsp under $(TomcatPath)/lvyouzaike

index.jsp under $(TomcatPath)/lvyouzaike/admin where I wanna protect

Notice that in localhost everything runs well: when I type "localhost/admin/index.jsp", the login page is shown and I have to log on with correct name and password. Yet when I input "", it is there directly without the expected appearance of login.jsp.
So what's the problem? Thanks a lot for your help.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15949

I don't think you're supposed to do an encodeURL on the form doing the j_security_check. The J2EE container login/loginfail forms do not have their own URLs, but are managed entirely by the Tomcat server.

Also, if you define a Context in tomcat's server.xml, it should completely override all elements of a context defined in the WAR it references. The WAR META-INF/context.xml is only used when there's no explict server-defined context.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: tomcat authentication not working
Similar Threads
Login authentication using tomcat7
authentication to support LDAP or database
Cannot Connect to database using datasource realm
how to redirect to success page in tomcat using its lapd configuration