Please let me first of all say that i am not a native englisch speaker. So don't take care about my mistakes.
I actually programming Webapps wiht Tomcat 6.0.20 on eclipse 3.2.
Recently i develop a webapp that correctly work, with authentication (form-based) via setting Realm on server.xml and security-constraints on web.xml
Now i tried to do the same with another application. But it didn't work!
1. I wrote another Realm in the server.xml
2. and I add the security-constraints for web.xml (the second webapp, the firts allready has it one)
3. The first application still work without problem
4. The second doen't work at yet!
If you actually defined multiple Realms in the server.xml, there would be a problem, since there's no way for a selected webapp to know which Realm to use. You should only define the Realm to server.xml if the same Realm applies to all webapps. Or at least all webapps that don't defined their own Realms.
Otherwise, define the Realm that the app will be using in the webapp's Context definition. That will settle which app uses which Realm, since they'll both be defined together.
Welcome to the JavaRanch! Your English is not a problem. English-speaking developers aren't very good at English a lot of times, either.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Dec 30, 2009
Thanks for the response.
I had holyday, but i currently back to my job.
I understand what you say, but no correctly. Please what do you mean with webapp's Context definition?
Where must i define the Realm?
where must i define the security constraints?
The Realms are now stored in server.xml. Must i erase all this Realms? And where must i write each of them?
I don't understand what you mean with Webapp's context. My Tomcat folder (webapps) doesn't have a webpp-name like showing in eclipse
All Java webapps are defined as WAR files. A WAR is a JAR set up according to the needs of J2EE as documented in Sun's J2EE standards.
Tomcat supports "exploded WARs", which are WAR files that have been unzipped. It will not make an operational distinction between a true WAR file and an exploded WAR. Not all webapp servers support exploded WARs. They are not part of the J2EE standard.
TOMCAT_HOME/webapps is a directory where you can place WARS and they will automatically deploy, although they will operate under default environmental values. You must define a webapp context file (see hyperlink above) if you want to override those values. In the cases of Realms, JDBC connection pools and alternative context names, you will have to define an explicit webapp context.
If there is no webapp context definition, the name of the WAR file (omitting the ".war" extension) or the name of the directory (for an exploded WAR) are used by Tomcat as the webapp's context name. An exploded WAR must all be contained within a single directory. In other words, you cannot place the WAR's files directly in TOMCAT_HOME/webapps. Likewise, if you provide a context definition that points to an alternative location, that location (codebase) has to be the pathname of a directory (for exploded WAR) or of a WAR file.
The context name is used to synthesize the model URL. If the context name is "myapp", a default Tomcat URL for myapp and its resources would be "http://localhost:8080/myapp".
Tomcat also comes with a default root context "/", which brings up the Tomcat admin pages. Unless you really know what you're doing, it's best to leave this alone.