File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Connection between a standalone application & a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Connection between a standalone application & a Servlet" Watch "Connection between a standalone application & a Servlet" New topic

Connection between a standalone application & a Servlet

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276

Can anybody please give me a solution regarding how o connect a servlet & a standalone application like a swing program.if anybody knows ragrding this please reply me as son as possible.

Thanking you,


The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
There's several options you can investigate.
One would be to use Http requests (usually, though servlets can in theory be deployed on servers using other protocols) to communicate with the servlet engine just like a web browser would.
This approach has the major advantage that your servlets don't need to change in any way, they don't even have to know it's not a browser that's connecting.
Your application may need to be more complex than you want it to be though, especially if you need to maintain state between requests (and thus need cookie handling).

Another approach would create an extra service in each servlet, listening in on a standard TCP port. This system could alternatively use RMI as a protocol.
Your application would place calls to this port and the servlet would then be triggered internally by that service.
Of course this means major changes to your servlets.

Last but not least is a kinda hybrid solution which is to implement your servlets to provide SOAP services.
This is now probably pretty much the standardised solution.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

  • RMI

  • JMS


  • Web-Services

  • JMX


    Which is right for you?..
    It depends on what you're doing.

    Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
    I agree. Here's the link:
    subject: Connection between a standalone application & a Servlet
    It's not a secret anymore!