This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Can a servlet listen to something else than http port.. and talk other protocols  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
a very greenhorn question:
Can I design/code an servlet, that - once it's loaded -- listens to a different http port (e.g 25/SMTP or pserver and talk in that protocol? Could someone point to sample code?
THX!
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet can do just about anything any other class can do - that does not mean it is a good idea. The port and protocol on which your servlet sees requests and responses is fixed by the servlet engine.
You would get better results and not get tangled up in problems of Threading, etc. if you created a separate class (possibly a separate application) to do work on other ports and protocols and have a servlet that can talk to that other class when needed.
Bill
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

...created a separate class (possibly a separate application) to do work on other ports and protocols and have a servlet that can talk to that other class when needed...
Bill


Thx Bill for the answer. Did I get it right:
- I create a standalone Java app that handles my port xyz and then talks to the servlet or the servlet talks to it. For the later a subscriber pattern seems appropriate?
To twist the question a bit: If the servlet can listen on port 80 (or 443), but the "talk" coming in is not http but the protocol/syntax used by a CVS client. Would that be a feasible use for an servlet?
Thx
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!