File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Swing With Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Swing With Servlets" Watch "Swing With Servlets" New topic
Author

Swing With Servlets

Sachin Dimble
Ranch Hand

Joined: Dec 07, 2005
Posts: 100
Hi ranchers!
I developed a simple servlet with a swing frame which communicates with oracle DB it's working fine but the problem is that if i closed the swing frame my tomcat get shut down!!

Could anybody explain why is it so? And how should i avoide it? Also i want to know how should i embeded my swing in to servlet??


Thanx In Advance!

Sachin. :roll:

- India_Will_Become_SuperITPower(new Lets_Go_ForIt());
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Servlets run in the context of the server. If you call something like System.exit(), you're going to shut down the server.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

You might want to explain exactly what it is you are doing. Mixing swing and servlets makes as much sense to me as mixing Cheez Whiz with motor oil.
Sachin Dimble
Ranch Hand

Joined: Dec 07, 2005
Posts: 100
Thanx Bear For ur Response!

If my swing application terminates only that instance should get closed but what i am facing is my tomcat got terminate. if i tried System.exit(0) explicitly in any servlet tomcat shows error :Failed shut Down of Apache portable runtime.

And why i am doing all this stuff is just want to check the support for swing in tomcat???

Hope u undrstand what i mean!!!

Thanx & Regards,
Sachin.

- India_Will_Become_SuperITPower(new Lets_Go_ForIt());
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

If your swing application is starting tomcat, exiting the swing app will close tomcat. Start tomcat seperatly. Otherwise, you need to just close the main frame but do not exit the vm, as bear stated.


GenRocket - Experts at Building Test Data
Sachin Dimble
Ranch Hand

Joined: Dec 07, 2005
Posts: 100
Hey Gregg, I am starting my tomcat seperatly. when i request for servlet my swing get started as i am making instance of swing at starting of servlet!!!

Thanx & Regards,
Sachin

- India_Will_Become_SuperITPower(new Lets_Go_ForIt());
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
if i closed the swing frame my tomcat get shut down!!

I suggest you need to change the code that handles the swing frame close event. If it is boilerplate from some IDE it may be doing a System.exit() as suggested by Bear.
Also i want to know how should i embeded my swing in to servlet??

Short answer: Never
You need to refactor your code so that it does not need Swing at all. Server side code intended for serious use should not depend on the GUI on the server machine.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing With Servlets