aspose file tools
The moose likes Servlets and the fly likes Servlets and Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets and Swing" Watch "Servlets and Swing" New topic

Servlets and Swing

Nishith Prabhakar

Joined: Jul 25, 2001
Posts: 12
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,

-----BEGIN GEEK CODE BLOCK-----<BR>Version 3.1<BR>GCS/CC/IT d->+ s: a-- C++(++++)$ ULH+>++++ P>P++ L+(++)$ E+ W+(++) N+>++ o? K? w++>+++<BR>O--- !M V? PS+(-) !PE Y+ PGP->+ !t !5 !X R->* !tv b+>+++ DI !D<BR>G+(++) e>+++ h@ !r y-*<BR>------END GEEK CODE BLOCK------
a hui
Ranch Hand

Joined: Oct 14, 2000
Posts: 39
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.
Nishith Prabhakar

Joined: Jul 25, 2001
Posts: 12
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

Joined: Jun 25, 2001
Posts: 16458

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
Nishith Prabhakar

Joined: Jul 25, 2001
Posts: 12
Thanks a lot,
yeah, i think that will do ...
I agree. Here's the link:
subject: Servlets and Swing