Hello,

My issue can be related to Servlets, but it also can be related to Tomcat.
I'm using tomcat 7.0.27.
In my servlet's post method I have the following:

protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {

    if
(this.hasCredential((String)request.getSession().getAttribute("auth_cookie")))
{

        String mac = request.getParameter("subscriber_mac");

        Processing.logoutSubscriberByMac(mac); //this is important

        request.getSession().setAttribute("subscriber_id",
request.getParameter("subscriber_id"));

        response.sendRedirect("/page/to/redirect");

        myLogger.info("subscriber with mac " + mac + " logged out by
administrator " + request.getSession().getAttribute("username") + " from
host " + request.getRemoteAddr()); //take care of this also

    } else {
        //treat this case ...
    }

}

TheProcessing.logoutSubscriberByMac(mac) has that code on it:

public static void logoutSubscriberByMac(String mac) {
    try {

        Process proc = Runtime.getRuntime().exec("logout subscriber
command");
        proc.waitFor(); //here is the problem

    } catch (IOException e) {

       //treat this error

    } catch (InterruptedException e) {

        //treat this error

    }

}

The problem is that if things are like how are presented above, the servlet
does not redirect the page:response.sendRedirect("/page/to/redirect");.
Even if the logs are written: mylogger.info("subscriber with mac ..."), the
browser tries to redirect, but it gets stuck on redirection and after
loading timeout, the browser's failure page appears. If I comment the line
that contains command to wait, proc.waitFor();, everything works well.
Even more, I tried to get the exit value from Process and it returns 0.

Question: Do you have any idea where the problem comes from? Can you give
me some suggestions?

Note: I redirect all traffic that comes to Apache HTTP server to Tomcat
through AJP Connector. But I think that shouldn't represent an issue for
that scenario taking in account that all other redirects are working great.

Reply via email to