-1

I want to create a static web page (same content to all clients).

In the meantime, I want to run the site as follows: - Double click on the html file. (So if I'm not wrong, I don't need server side, i.e apache tomcat). (I want this for now, in order to make progress in logic)

The static web page will contains:

  1. browse button
  2. OK button
  3. (by 1&2) when the user choose a file and click OK I want to open a tcp connection to a remote appliation and exchange some data.

Several Q's:

  1. How can I use java code (to send/recive messages) in HTML files (after the user click on "OK") ?
  2. Do I need to use JSP & TOMCAT ? (I want somthing that will be use for my interest only, and will not be as a internet web page)
mpromonet
  • 11,326
  • 43
  • 62
  • 91
Azil
  • 457
  • 2
  • 5
  • 10
  • 1
    It's hard to understand what you're asking for. If you want to run Java in a web page you need an applet. If you just need to exchange some data with a server from a static page why not just use Ajax or WebSockets? – Dave Newton Jan 03 '15 at 14:39
  • Look at this http://stackoverflow.com/questions/12407778/connecting-to-tcp-socket-from-browser-using-javascript See if it help you... the first part for now – Dilson Eifert Jan 03 '15 at 15:01

2 Answers2

1

If you reliably want to run code on a web page without interacting with the web server to do so, you need to use a language native to the browser.

As of 2015 that would be Javascript (which is a very different language than Java).

Interacting with the web server is then typically done with AJAX calls, where the part of your code running inside the browser exchange data with the part of your code running inside the web server. The front end code is again typically written in Javascript and the backend code in whatever the web server supports.

Note that after you have done some initial experiments, most likely will need a framework to make this easier to do for non-trivial behaviour.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

@1: I am not sure what you are heading for, but Google Web Toolkit could help. Basically it splits your application in a client and server part, all written in java, but the client part gets compiled to javascript. This way you can develop all in java and bootstrap it within ANY html page.

@2: Easiest way would be to write the server in java and host its war-file with a jenkins. But there are much more possibilities including a non java server.

Journeycorner
  • 2,474
  • 3
  • 19
  • 43