2

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.

js0823
  • 1,843
  • 8
  • 24
  • 36
  • possible duplicate of [Create a simple HTTP server with Java?](http://stackoverflow.com/questions/2717294/create-a-simple-http-server-with-java) – Mat Jun 26 '12 at 20:10

4 Answers4

6

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.

Tom
  • 1,414
  • 12
  • 21
  • Thank you for your response. Others have pretty much said the same thing. This answer was most clear to me. I was hoping to create a very simple webpage to demonstrate something and I was therefore thinking about using the least library as possible, but I guess it's easier to just listen to what others say :D – js0823 Jun 26 '12 at 20:28
  • I was assuming you wanted to create a dynamic web page. If you only want to have a static page with some static buttons and text, you can simply write an html file and open it in your browser. But I'm probably stating the obvious here :) – Tom Jun 26 '12 at 20:57
  • 2
    You should also consider Jetty if you want something lightweight to run your servlet container. Tomcat is good, but it's quite a bit heavier than Jetty. – Matt Jun 27 '12 at 03:06
  • you deserve a award man. I asked the same to my college teacher they ignored 15 times.. – Akash Sep 11 '20 at 11:02
3

Creating the server piece could be done with raw sockets, but I would look at at an embedded server like Jetty. I think it will save you a lot of time and headache.

http://docs.codehaus.org/display/JETTY/Embedding+Jetty

tjg184
  • 4,508
  • 1
  • 27
  • 54
1

You should look into Play Framework. It will be easier then implementing Tomcat or Apache.

Version 1.2.4 is stable and feature-complete for Java, version 2.x is focused on Scala and doesn't have all the features of 1.2.4 yet.

Peter Di Cecco
  • 1,548
  • 5
  • 15
  • 26
1

You don't have to create a servlet. But, you need something that can parse a jsp page - it could be tomcat or some other server which has the same capabilities as tomcat. Though I am not sure if I understood your question correctly.

FSP
  • 4,677
  • 2
  • 19
  • 19