0

I'm trying to create a tiny web server to route information between client applications for a Diffie-Hellman Key Exchange encryption system. Sadly, I have very little experience with Java networking. What would be the best way to set up a server to receive values from user A and pass it onto user B, and vice versa? I've looked into servlets with Tomcat/Google App Engine, but they appear to be mainly dealing with HTML webpages. I've tried using sockets, but I am not sure if I can host a ServerSocket application on the internet.

What is the best way to achieve this goal?

2
  • your servlet does not have to output html, it can output anything, you have full control of the output stream. Tomcat is actually a ServerSocket application, so if you can host that, you can host anything. Commented Sep 14, 2013 at 4:02
  • Have you looked at the netty-library? It is very simple to get a webserver up and running with it. netty.io Commented Sep 14, 2013 at 5:47

2 Answers 2

1

I've looked into servlets with Tomcat/Google App Engine, but they appear to be mainly dealing with HTML webpages.

That is incorrect.

While it is true that most examples you will find deal with HTML webpages, the Servlet framework is equally suited to sending non-HTML responses; e.g. JSON, XML ... or basically anything that you can turn into a bytestream.

I've tried using sockets, but I am not sure if I can host a ServerSocket application on the internet.

Implementing an HTTP server at the Socket level is significant amount of work to do properly ... including a lot of HTTP specification reading! Frankly, it is not worth the pain and effort unless you have extreme performance requirements. (And if you do, you probably shouldn't be using Java ...)

What is the best way to achieve this goal?

For something simple without onerous performance requirements, an stock servlet container like Tomcat, Jetty or GAE should be fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! After a little bit of tinkering, Tomcat works perfectly.
0

IMO:

When we have two applications and they want to communicate with each other, then we make use of web services. You can make use SOAP based WSDL webservices or RESTful webservices. Later is more popular now a days.

Making use of existing frameworks will make your life easier without having to re-invent the wheel.

All the best.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.