Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Swing With Servlets  RSS feed

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets run in the context of the server. If you call something like System.exit(), you're going to shut down the server.
 
Bear Bibeault
Marshal
Posts: 67163
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sachin Dimble
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!