Sending serialized objects back and forth is one approach; another is to make the admin app just a "thin client" with everything happening on the server; the server would provide a separate, rich interface (via web services, perhaps) which the admin app would use to communicate with it. Personally I'd choose this latter approach.
I always like pictures. See if this looks like what Ernest said:
The browser uses standard HTTP and gets back HTML. I usually like a servlet that receives the request, delegates to a plain Java object that interacts with the services, and then forwards to a JSP that builds the HTML response.
The Swing client does all its own presentation so it doesn't need HTML. It uses HTTP GET and POST again to communicate with a servlet. This servlet delegates to a plain Java object that interacts with the services, but then returns XML.
The biggest difference might be the "thing" that converts service output to HTML in one case and XML in the other. Another difference is that the second servlet can be a lot simpler.
This is such a common scenario that there are many tools to help you expose services as web services and consume them from the client end. On the other hand, it's really very easy to build your own and probably worth the education you'd get the first time around.
Having fun yet?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Mathias Nilsson
Ranch Hand
Joined: Aug 21, 2004
Posts: 367
posted
0
Thanks!
That all sound good but to be frank i don't really understand exactly what you are talking about. Perhaps I'm not quite that skilled in java yet.
I don't really have to use JSP because it is not a "real" web application It is an applet that is signed. The applet interacts with servlets on another webserver. I have control over both of the servers.
What I mean is the users only use the applet. Drag and drop files drags boxes etc in the applet. The data needs to be saved to database. I can't communicate with the database directly from the applet because the users won't open the port in their firewall so it needs to be done over port 80.
// Mathias
Louis Moloney
Ranch Hand
Joined: Feb 06, 2007
Posts: 59
posted
0
maybe im missing something here, but why not:
1. send the data from the applet to a servlet (HTTP port 80). 2. get the servlet to write the data to the database
then no need to mess around with any firewalls on client machines.
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
How do you communicate from the applet to a server now? With HttpURLConnection? In that case, it's working just as the "fat client" path I drew above.
Mathias Nilsson
Ranch Hand
Joined: Aug 21, 2004
Posts: 367
posted
0
Hi!
Yes I use HTTPURLConnection to communicate with servlets. I set the content type to post and receive java objects. Rather tedious to copy all classes that needs to be serialized from servlet to applet though.
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
Rather tedious to copy all classes that needs to be serialized from servlet to applet though.
Why is that? How do you "serialize" them across the wire? If you find XML too painful I won't disagree. Look at JSON for a simpler alternative.
Mathias Nilsson
Ranch Hand
Joined: Aug 21, 2004
Posts: 367
posted
0
I implement the Serializable interface and post them from applet to servlet. In the serlvet I receive the response cast the data and do the logic. Often I post back an object so that the applet knows that all was ok.