Closing application not working

I have two vaadin application running on same tomcat. (configured 2 vaadin servlets). I want to redirect from 1 application to the other if system is in production mode (a param in web.xml)

Application1 is mapped to lets say http://xyz.com/application1

and application2 is mapped to certain url lets say http://xyz.com/application2

now in init method of application2 I am saying following:

if (productionMode) {
setLogoutURL(“http://xyz.com/application1”);
close();
}

The above code for sure executes, but the code keeps on going and loads main window (that code is after above).

So any idea how to solve this? Perhaps init is not right place to close application? What can be better way to achieve this

Hi,

It would be
way better
if you could set it up so that the redirect happens
before
any application is started, either by configuring your server (best) or by extending
ApplicationServlet
and redirecting in the beginning of
service()
.

Having said that, if you must do this from within the application, I can think of two ways, use a
TransactionListener
:

getContext().addTransactionListener(new TransactionListener() {

            @Override
            public void transactionStart(Application application,
                    Object transactionData) {
                if (productionMode && application == AtestApplication.this) {
                    setLogoutURL("http://vaadin.com");
                    close();
                }
            }

            @Override
            public void transactionEnd(Application application,
                    Object transactionData) {
            }
        });

or override
Application.start()
:

@Override
    public void start(URL applicationUrl, Properties applicationProperties,
            ApplicationContext context) {
        super.start(applicationUrl, applicationProperties, context);
        if (productionMode) {
            setLogoutURL("http://vaadin.com");
            close();
        }
    }

But once again, I recommend redirecting before the application is started - maybe a redirect filter in web.xml or something.

Best Regards,
Marc

Thanks, I think your suggestion is valid that I need to handle it before even application starts. So I have done it using filter.

I usually install my favorite app on my phone at this android store: [https://iplaystoredownloadfree.com/]
(http:/https://iplaystoredownloadfree.com/)

How about you? You already have your favorite store. You are finding. You are worried there is no store that suits you. I will introduce you to free quality stores. These are the stores for you to refer to and install by following the instructions:

Hope you love the store on!