On Thu, Nov 22, 2012 at 10:33 AM, Konstantin Kolinko <knst.koli...@gmail.com
> wrote:

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

The process execution (call to Processing.logoutSubscriberByMac(mac))
normally should take less than 1 millisecond.


> >
> >         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
>

the logs are filled in files immediatelly after that servlet is loaded.


> >
> >     } 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");
>

again, if the command is run in CLI, it takes laess than 1 millisecond.


> >         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.
>

The browser tries to redirect for about 30 second.


> 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.
>

I doubt the process would take more time to succeed than browser's page
loading timeout only for the reason that I run that command from java.
Actually, if I check to see if command is fulfilled during page loading,
the result is ok.

N.B. I also managed the Process streams, (getInputStream, getErrorStream),
but without result.



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

Reply via email to