I have a configuration page in my app. When user changes configuration and submits it, I would like to reload my application with new configuration properties and then redirect to some page. I was able to reload my application using some suggestions I found here Start / stop a web application from itself?
but I am not able to redirect to new page after the application has reloaded.
More details.
public class ConfigurationServlet extends HttpServlet implements ContainerServlet{
    private static final long serialVersionUID = 1L;
    private SalsaEnvironment salsaEnv;
    protected Host host = null;
    protected Wrapper wrapper = null;
    protected Context context = null;
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // update configuration properties
        .
        .
        . 
        // reload app once configuration is changed
        restartWebApp(resp.getWriter(), "/salsadb");
        // simple redirect/forward - does not work - gives following exception
        // java.lang.NullPointerException org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
        //resp.sendRedirect("/salsadb/account");
        //req.getRequestDispatcher("/account");
        // invalid old session, create a new one and try to redirect - does not work
        req.getSession(false).invalidate();
        req.getSession(true);
        req.getRequestDispatcher("/account");
    }
    @Override
    public Wrapper getWrapper() {
        // TODO Auto-generated method stub
        return this.wrapper;
    }
    @Override
    public void setWrapper(Wrapper wrapper) {
        this.wrapper = wrapper;
        if (wrapper == null) {
            context = null;
            host = null;
        } else {
            context = (Context) wrapper.getParent();
            host = (Host) context.getParent();
            Engine engine = (Engine) host.getParent();
            try {
            } catch (Exception e) {
                // ?
            }
        }
    }
    private void restartWebApp(PrintWriter writer, String path){
        if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
            System.out.println("invalid path");
            return;
        }
        String displayPath = path;
        if( path.equals("/") )
            path = "";
        try {
            Context context = (Context) host.findChild(path);
            if (context == null) {
                /*writer.println(sm.getString
                               ("managerServlet.noContext",
                                   RequestUtil.filter(displayPath)));*/
                System.out.println("no context");
                return;
            }
            context.reload();
            //writer.println(sm.getString("managerServlet.reloaded", displayPath));
            System.out.println("reloaded webapp");
        } catch (Throwable t) {
            log("ManagerServlet.reload[" + displayPath + "]", t);
            /*writer.println(sm.getString("managerServlet.exception",
                                        t.toString()));*/
            System.out.println("excpetion during reloading the webapp");
        }
    }