Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Between java.net package or servlet class, which is better

 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my project, it has two servers named SMS-GW and CP. They communicate to each other by HTTP(s) socket. In CP server contains Tomcat, DBMS to provide a JSP Website (used the Struts Framwork, too :-). The SMS-GW server sends various parameters to the CP server through HTTP POST method.
I don't know between java.net package or servlet class, which one is better to implement?
Thanx in advance.
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If both server are using HTTP protocol for comminication .. IMO its better to implement in servlets.
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I didn't understand, but it seams that CP is a web applications (you mentioned Struts, database, etc), so in this case, your application shouls implement a servlet.
However, it seams to be that SMS-GW is only a client, that sends only request to CP. In this case, you don't need to write a servlet (with another tomcat installation). Just write a simple java aplication and use URL.getConnection() to send you data to the servlet.
java.net package has low level IP/TCP/UDP connection funtionality. You can also use it (class Socket) to let SMS-GW tcp-connect to you server via port 80, but I suggest to use URLConnection intead.

Dani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic