简体   繁体   中英

java at server-side attached with html

I am developing a card game. I coded my client side (front end) in html, jquery and javascript , the server-side is in Java (shuffling, distribution and rules of games)

How can I join my html with the Java backend. Is that possible using JSP, or any other technique?

Until now I am taking input in java through scanner but after the clientside is attached it will be from htmlpage. How can I be able to do it?

For such games with a java server, you have two main solution types :

1) using a templating system like JSP to generate the pages server side

2) using ajax client side and communicating using JSON (using standard ajax or websockets)

I used both types of solutions.

Now I would clearly recommend using ajax as it enables more fluid and fast interactions for the user. If you can accept to be incompatible with old browsers, I would recommend websockets as they enable very fast and light sending of information from the server to the browser, which is generally needed in multi-player games (that's what I'm using now).

Have a look at this :

http://jwebsocket.org/

http://java.dzone.com/articles/creating-websocket-chat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM