2012/11/21 Andrei Petru Mura <mapand...@gmail.com>:
> 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
>
> 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?

The browser times out = it closes the connection before the response
arrives = it closes the connection before you write your response.
There is no wonder that it does not see the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to