File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat BASIC Authentication Problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat BASIC Authentication Problem." Watch "Tomcat BASIC Authentication Problem." New topic

Tomcat BASIC Authentication Problem.

Nicholas Jackson

Joined: Apr 02, 2011
Posts: 2
Hello, I'm new to Tomcat, and I am having an issue with setting up basic authentication for my app. I have the last Tomcat installed (6.0.32) and it is serving out a web application called Geoportal. To add an extra level of security I wanted to apply Basic authentication for this app and I successfully did so, the authentication login screen opens when I go to http://localhost:8080/geoportal/. However, after successfully signing into the page once I click to go to a new page in the app I makes me login once again.

What am I missing, I feel that once I sign in at the beginning it should retain my information in the memory so I don't have to re-authenticate. Could someone please help me with this or point me to a resource that could answer my question?

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Nicholas Jackson wrote: I wanted to apply Basic authentication for this app and I successfully did so

It looks like not very successfully How did you do it exactly?

Nicholas Jackson

Joined: Apr 02, 2011
Posts: 2
Yeah I guess not exactly successful

But below is the code that I placed in the server.xml, tomcat-users.xml, and the webapp web.xml



Webapp web.xml

Like I stated before it does allow me to login to the first page but when I try to go to any of the other pages, I get the login screen again.

Thanks in advance for any help.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

BASIC authentication doesn't use a login screen. Typically, the user's browser will pop up a modal dialog.

You didn't provide a lot of details, but I suspect that you wrote your own login code in the webapp. The security system in web.xml doesn't work with user-supplied login code, it employs login code that's part of the server itself (Tomcat). If you try and mix the 2 different types of security, unpredictable things can happen, but having a login that doesn't really log you in (as far as Tomcat is concerned) is not uncommon. And if Tomcat doesn't think you're logged in, it will continue to send login requests back to the user until you either attempt to access a non-secured resource (URL) or you log in properly.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Tomcat BASIC Authentication Problem.
jQuery in Action, 3rd edition