Search code examples
javawebserver

Add Web Interface to existing Project


I tried to understand this several times allready, but still have not found out how this should be done. I want to create a web interface for some existing console or swing application. Something like the web interface SABNzb offers (I know, it's Python – it's just an example).

I have looked at several technologies allready, like creating web services using a tomcat server, or java server pages/faces, but all the tutorials that I found so far start with "Create a new Web Project..." at wich point I stop because this is not what I want! I have a finished an application in which I want to integrate a web interface, not some web service that instantiates my program as a local variable and uses its code. So basicaly it feels like all the tutorials I find are the wrong way around.

The core procedure of this is clear, the application should listen for http requests on a port I choose and answer with a created html code to it. So basicaly I could open a port using a socket and write an html page to its output on connect. But this rather feels like inventing the wheel all over again, also I'm not sure how an interactive web page would work this way.

Maybe I am thinking somewhat strange here or did not understand how some of these things work, but I am pretty unexperienced with web technologies, so grasping the concept is rather hard at the moment. Can anyone point me to a tutorial that shows how this might be done, or some other source of information on it?


Solution

  • You don't need JSP or JSF; all you need is a servlet. It's an HTTP listener class. You can do REST with that.

    The moment you say that you have to deploy your servlet in a WAR on a servlet/JSP engine. Tomcat is a good choice.

    Google for a servlet tutorial and you'll be on your way.

    My First Tomcat Servlet