Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets and Swing

 
Nishith Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
On the server side, i need the server administrator to interact with the servlet. Can i instantiate a Swing Component - Frames and Buttons from a Servlet (probably in the init() method) and still deploy the servlet on the server using Tomcat.
If not, what is the best way to build a server side tool which lets the system administrator change settings, becoz the servlet (or the replacement) has to use these settings to reply to a POST request.
What i was planning was to implement HttpServelet and implement doPost method to reply and at the same time use init() to instantiate a Swing JFrame which lets the system administrator change settings on the server. Is it possible ?
Thanks a lot,
Nishith
 
a hui
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood you correctly, you'll need to add an applet (or JApplet in swing) to your jsps or servlets. And then you'll have to figure out how the communication works between an applet to servlet and vise versa.
AH
 
Nishith Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not exactly ... i guess applets wud be used when the configuration is to be done from the client side ... isn't it ... i need the server administrator to change the settings ... so shudn't it be possible to just instantiate swing components and display from the servlet container ... in short ... do servlet container support components in the servlet.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't. I suspect that use of UI code is probably banned in the servlet spec - at least I can forsee a strong likelihood that you'll do bad things to the server.
You'd be better off coding the control functions in a web page and passing them in via a secured POST. That also will reduce any sort of synchonization problems you might get.
 
Nishith Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,
yeah, i think that will do ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic