wood burning stoves*
The moose likes Tomcat and the fly likes How to modify web.xml file at runtime??????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to modify web.xml file at runtime???????" Watch "How to modify web.xml file at runtime???????" New topic
Author

How to modify web.xml file at runtime???????

dheeraj chhabra
Greenhorn

Joined: Apr 09, 2004
Posts: 23
Hello all of you,
I m developing a security application using tomcat server.

I have to create security role and assign task to the created role....And i want that without restarting the Tomcat the changes i made in the web.xml file related to this "Role".

So, my question is ---
what parser should i use to modify existing "web.xml" file???

I mean i just want to add and delete Tags in existing web.xml file without deleting, modifying and then creating new file.....

Please help me out............

Thanks in Advance

Regards
Dheeraj
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Some points that may help you:

- This page talks about how to set up Realms in Tomcat. You didn't mention where your user database lives; the simplest way would be an XML file called conf/tomcat-users.xml, in which case you need to configure a MemoryRealm.

- Some starting points how to configure your web.xml file can be found here, or, of course, in the servlet specification.

- Whenever you make a change to web.xml, the web application needs to be restarted to pick up those changes. Tomcat does not need to be restarted.
If you use MemopryRealm, though, the whole Tomcat server needs to be restarted.

- I'm not sure about your question concerning an XML parser. web.xml is an standard XML file; you can modify it with any DOM tool you like (XOM, JDOM, DOM, ...), but a parser alone will not be sufficient.
But you still need to restart the web app, no matter how you modify the file.

- To sum it up: If you want to change dynamically which pages are protected, and which users can see those, the standard security features of web apps are insufficient - you need to implement something yourself. If you just need to add new users or remove them at runtime, use a JDBCRealm, which looks up authorized users in a database.
[ August 26, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
dheeraj chhabra
Greenhorn

Joined: Apr 09, 2004
Posts: 23
Thanks Ulf Dittmer for ur kind reply......But sir i just want some more pouints from ur side:

Actually, i just want to Add and delete "security-constraint" tag in my web.xml file.

And i want the changed effect in my web application without restarting the tomcat server.

Would you please help me out in this context???

thanks in advance

Regards
Dheeraj
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
Actually, i just want to Add and delete "security-constraint" tag in my web.xml file.

Re-read my previous post. It's an XML file - you can change it any way you want, and the way you do it has nothing to do with web applications. Personally, I might use XOM, but you may have a different preferred DOM library.


And i want the changed effect in my web application without restarting the tomcat server.

Re-read my previous post. Restarting Tomcat is not necessary. Restarting your web application is necessary.
[ August 26, 2005: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to modify web.xml file at runtime???????