Creating a simple web page using Java without using Servlet and Tomcat

js0823 picture js0823 · Jun 26, 2012 · Viewed 16.3k times · Source

I want to create a simple server application which runs on the desktop, and when I type my ip and port on the web browser, it connects to the server client which then opens a webpage with appropriate displays coded on the server application.

I read online that I need to use servlet and Apache Tomcat to make a webpage using Java.

I am wondering if there are any easier way to make a simple webpage which can contain buttons without using servlet and Apache Tomcat?

For example, I can use sockets to communicate between server and client applications. Could I change this client into typing the ip address and port on the web browser which will display a webpage created and contained in the server application and remove the need for servlet and tomcat? If so, how do I create a button on the server application so that web browser can see the button when connecting to the server application?

Thank you very much.

Answer

Tom picture Tom · Jun 26, 2012

If I understand you correctly, you want to have a web page, but you don't want to use Tomcat (or any other servlet engine).

Although it is technically possible to write your own little web server (using server sockets etc), but what you're basically doing then is rewriting Tomcat. Writing a good web server is a daunting job, and should not be taken lightly. I think you are underestimating that. Instead, use what is already there. Tomcat is really quite easy get running.