tags:

views:

92

answers:

3

Hi all,

Here is my problem statement- I have an application in webapps of tomcat. I want to run the application in the browser only after checking the licence of the software. Is it possible to stop the application from running, whereas allowing other wars to run in the browser.

Thanks, Adi

+3  A: 

Is this for your own application or for third party software?

If its your own application then you could write a filter to check that the license is valid and then to redirect to an error page if it has expired.

Alternatively you could just throw an Exception...

pjp
And configure that (javax.servlet.Filter) filter in the apps web.xml of course.
extraneon
Yes I could use a filter and do the job. But I have been asked to check if its possible to stop the war itself from running... Is it possible to check this using any method?
Aditya R
You could add a ServletContext listener that decides if the app can run at startup and if not it could throw an exception. The only thing is that this check will only happen each time the application is started up.
pjp
Thanks a lot I'll get back after trying it out.
Aditya R
+1  A: 

If you just mistyped your question:

Nice article about different ways of seting up authentication in a webapp http://www.javaworld.com/javaworld/jw-04-2000/jw-0428-websecurity.html

Peter
A: 

No. There is no standard API for deploying/undeploying web application, so you cannot do this in a web container agnostic way.

You can, however, ensure that all public entry points throw a servlet exception so you get redirected to the error page, where the license must be accepted.

Thorbjørn Ravn Andersen
Thanks a lot for your reply. I understand your point,but I was asked to find out if there is a way to stop a web application from coming up by giving a condition in the servlet container. What do you think of stopping using ant?
Aditya R
This won't work. Write your application to explicitly check.
Thorbjørn Ravn Andersen