• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

A Realm for more than one Webapp

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 28108
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Gerry Mueller
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28108
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
ice is for people that are not already cool. Chill with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic