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

GUI based webserver servlet access

inam reyi
Greenhorn

Joined: May 11, 2004
Posts: 7
Hi ,
I would like to know if i can have a swing GUI app. which needs to connect to an already existing Webserver application with JSP/Servlet on websphere.
can i execute the servlets, from this standalone GUI app. but without using HTTP protocol. can RMI be an alternative, Pls elaborate if yes .

Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Yes, you can use servlets as a backend to a Swing app. You can use RMI HTTP tunnelling or Web Services. RMI HTTP tunnelling wraps RMI calls in the HTTP protocol, and Web Services translates method calls to XML-RPC wrapped in SOAP messages.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
inam reyi
Greenhorn

Joined: May 11, 2004
Posts: 7
Thanks Nathan.
I was able to run the tutorial for RMI http tunnel, but i dont see any RMI
code or any classes relating to it. It would be great if i can have the entire code , would be better for me to understand. Thanks once again.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by inam reyi:
It would be great if i can have the entire code

Isn't that part of the project file listed in the Resources section of the article?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
By the way, that IBM developerWorks article isn't about tunneling RMI over HTTP but simply about sending any serialized Java objects over HTTP.
inam reyi
Greenhorn

Joined: May 11, 2004
Posts: 7
i would appreciate if anyone could provide a link or code example for Swing using RMI to access data from a servlet running on say tomcat .
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sorry, I went back and read your post more closely... If I understand correctly you have an existing JSP/Servlet app that you want to build a Swing client for. I read your post too fast and thought you were asking in general how you could use the web tier to provide some kind of distributed back end capability for a Swing app.

In this case, with an existing web app, RMI HTTP Tunneling (an appropriate link this time Lasse ) probably isn't what you should be looking into - mainly this is used to get around issues where a firewall blocks the normal RMI server mechanisms, and a servlet provides a Proxy that wraps the RMI call in HTTP. Since you don't have an existing RMI app, this probably isn't what you want to do.

Web Services may still be a good option...

A lot of this depends on how your existing JSP/Servlet app is built and what it does... does it use Model 2/MVC architecture? If so, it would be much easier to swap out the JSP frontend and replace it with a Swing frontend. (Basically what you would do is have an alternate controller servlet that passes you serialiazed versions of beans, rather than having it put the beans into request/session/application scope for a JSP to use. ) Is it using EJBs or some other form of back-end storage for data used in the Servlet/JSP app? It might be easier to access the back-end data directly from your Swing app.
inam reyi
Greenhorn

Joined: May 11, 2004
Posts: 7
Thanks Nate,
My jsp/servlet app is a very old one , the prob is both are tightly coulpled for DB calls etc. its more of a client server kind of app, where even in JSP there are db calls ( very old system ) , so now i need to somehow have this Swing GUI , since it takes hell of a time for the webpage to get refreshed, whereas it will be much more faster in GUI , now which is the best possible way to use GUI instead of Jsp
which means i need to make GUI to communicate with servlets. so i was thinking if RMI can help me here. basically i do not want to redo the entire app since its working fine except for the Slow refresh JSP ( since its on http )
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

If the web app is refreshing slowly, this is due to the latency of the network or the time it takes to generate the information on the server. It isn't because the browser is taking a long time to generate the HTML you are sending it, so it isn't going to be fixed by just making a GUI application. It's a better idea to find out what is causing your existing application to be slow to respond and fixing that - put some debug code into the app and time how long it takes for it to do different parts of the application. Since it sounds like the existing app is making DB calls directly, make sure you are saving the DB connection somewhere (like in application scope) so it doesn't have to be created all the time (if you aren't already doing this), and think about caching information that doesn't need to be re-read from the DB all the time.
inam reyi
Greenhorn

Joined: May 11, 2004
Posts: 7
Hi,

This change is needed in terms of GUI look and feel and also for speed of opening up of windows , which is agreeably faster in SWing GUI than HTML, thats the reason for going in for Swing too.
and there is a solution using socket communication where we can use a Swing client/server communication via sockets, but i want to avoid this and use RMI instead to integrate with the current jsp/servlet app we have.
Any info ( examples ) for this issue would be helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI based webserver servlet access