• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

GUI based webserver servlet access

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .

 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
inam reyi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Acetylsalicylic acid is aspirin. This could be handy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic