• 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

Communication between 2 applications - Servlets?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys. I have two distinct applications, one is a Web application running in Tomcat, which uses Spring and JSF, and this application has a class with a method that does a insert operation in a Postgre database. The other application is a simple desktop application, which I use to do some text files manipulation and conversion. They both are in the same network (right now in the same machine, but I want to be able to run each one in different machines). What I need to do is: when I execute the desktop application, I want to get the data from the text file, and pass this data as variables to the Web application and run the method from the Web application that does the insert, inserting this data into the database. I know I can do this with RMI and with Servlets, but I don't know how. My preference is to use Servlets. Could you give me any hint on how to do this? Thank you!

PS: I'm sorry for my poor english (I'm from Brazil)!
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"URL" and "URLConnection" approach to contact the Servlet from the thick client application.

http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html

1.) Set the URL of the servlet in URL class instance and open the URLConnection.
2.) Establishing the OutputStream to the Servlet URL. The text content can be sent in OutputStream and
consumed in InputStream in Servlet side...

Without affecting the existing Servlet code logic, you can write some Adapter class(try Filters) which intercept the text input from Thick Client and does some process and sends to the Servlet.

Otherwise, Web Services approach... which will make the applications in different platforms to interact each other...

 
antonio nunes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ram Narayan.M wrote:"URL" and "URLConnection" approach to contact the Servlet from the thick client application.

http://docs.oracle.com/javase/6/docs/api/java/net/URLConnection.html

1.) Set the URL of the servlet in URL class instance and open the URLConnection.
2.) Establishing the OutputStream to the Servlet URL. The text content can be sent in OutputStream and
consumed in InputStream in Servlet side...

Without affecting the existing Servlet code logic, you can write some Adapter class(try Filters) which intercept the text input from Thick Client and does some process and sends to the Servlet.

Otherwise, Web Services approach... which will make the applications in different platforms to interact each other...



Hi. Thank you for your reply. Ok, so in my Web Application I will create a Servlet class, and then Filters or Adapter class to intercept the data, which will be send by the client application, trough the URL Connection. I got that, but I'm kind of starting with Servlets, so if I'm not asking too much, could you give me some code examples, or maybe point to a tutorial where I could read more about this?
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just searched this Tutorial...

http://www.frank-buss.de/echoservlet/index.html

This is based on Applet-Servlet Communication... Since Applet is also standalone Java class, replace Applet with your Thick Client Java Class and you can get the touch of using URLConnection class to contact the Servlet
 
antonio nunes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ram Narayan.M wrote:Just searched this Tutorial...

http://www.frank-buss.de/echoservlet/index.html

This is based on Applet-Servlet Communication... Since Applet is also standalone Java class, replace Applet with your Thick Client Java Class and you can get the touch of using URLConnection class to contact the Servlet



Ram, I understood how I could do it manually with an Applet, or JSP, etc. Now the challenge is doing it automatically. Could you give me more information on how to do this using Adapters, or Filters, or other way? Thank you again!
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
paddy smith, your post was moved to a new topic. Please do no hijack other peoples' topics.
 
reply
    Bookmark Topic Watch Topic
  • New Topic