Hi All,
I have a very basic question. When i use any Swing components inside my
Servlet, after the execution the
Tomcat server gets shut down. Whereas if i use the components inside
applet and then use in the Servlet the server works fine. Can anybody explain me why does it behave like that?
Here is the code which caused the server to shutdown.
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.io.*;
import javax.swing.*;
public class GreeterServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
JFrame testFrame = new JFrame("Tester");
JButton testButton = new JButton("Hai");
testFrame.add(testButton);
testFrame.setSize(350,350);
testFrame.setVisible(true);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Please note that, the code provided above is only to understand the concept.
Thanks in Advance,
dinesh