Wolfgang Egger wrote:
> Servus,
> 
> I have a web-application, running from CD-ROM and I want the user to
> stop tomcat by klicking a link within this web-app. Tomcat is started as
> a embedded version from a Java-Application, but I don't want, that this
> start-application has a GUI. The only GUI I want to present the user, is
> the HTML-Web-GUI of the web-app running on tomcat.
> 
> I have tried to call System.exit(0) from a Servlet. It works so far, the
> server stops, but my browser (firefox) answers with an error-dialog
> (connection refused). What I want to have is, that the Browser shows a
> final-page (quit.jsp) and after that no more error-dialogs.
> 
> Has anybody any hint or idea?

I am guessing that you haven't flushed and closed the output stream
before calling System.exit() The following code works without error
for me.

HTH,

Mark


package org.apache.markt.users;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Shutdown extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException {

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
        out.println("<HTML>");
        out.println("  <HEAD><TITLE>Shutdown</TITLE></HEAD>");
        out.println("  <BODY>");
        out.println("    <p>Tomcat is now shutdown.</p>");
        out.println("  </BODY>");
        out.println("</HTML>");
        out.flush();
        out.close();
        System.exit(0);
    }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to