wood burning stoves*
The moose likes Tomcat and the fly likes A Realm for more than one Webapp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "A Realm for more than one Webapp" Watch "A Realm for more than one Webapp" New topic
Author

A Realm for more than one Webapp

Gerry Mueller
Greenhorn

Joined: Dec 30, 2009
Posts: 17
Hi,

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!

Please help me!
Thanks for all helpfull adds
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

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.
Gerry Mueller
Greenhorn

Joined: Dec 30, 2009
Posts: 17
Hi Tim,

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

C:\apache-tomcat-6.0.20\webapps
-- docs
-- examples
-- host-manager
-- ROOT

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Gerry Mueller wrote:Hi Tim,

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?

http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html#A%20word%20on%20Contexts

Where must i define the Realm?

You can define a Realm globally in server.xml. You can define a Realm for a single webapp in its context definition.

where must i define the security constraints?

/WEB-INF/web.xml


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

C:\apache-tomcat-6.0.20\webapps
-- docs
-- examples
-- host-manager
-- ROOT



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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Realm for more than one Webapp