• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TictTacToe jax-ws

 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Could anyone please let me know how to built the web-service for TicTacToe game (3*3grid) for multiple user sessions and client has to built using jsp

If anyone has come up with the code,please do post it.

Your reply will be highly appreciable

Regards,
Navya
 
Tim Moores
Bartender
Posts: 2749
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If anyone has come up with the code,please do post it.

No, we don't want to deprive you of the learning opportunity. What do you have so far, and where are you stuck making progress? The only place I could see JSP being involved is to generate the HTML page displaying the field, and to start a session. If a web service is to be used, you'd probably access it using a AJAX/JavaScript library (like Prototype or jQuery) from within that page.
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I am able to draw a 3*3 grid using:
public String drawBoard() {
StringBuilder builder = new StringBuilder("Game board: \n");
for (int i = 0; i < 3; i++) {
for (int i1 = 0; i1 < 3; i1++) {
builder.append("[" + board[i][i1] + "]");
}
builder.append("\n");
}
return builder.toString();
}
public void init() {
int counter = 1;
for (int i = 0; i < 3; i++) {
for (int i1 = 0; i1 < 3; i1++) {
board[i][i1] = counter++;

}
}

and able to get the 3*3 grid with 1-9 numbers in the console as follows:
[1][2][3]
[4][5][6]
[7][8][9]

My concern is how to integrate jsp UI fields to this 3*3 grid.

 
Tim Moores
Bartender
Posts: 2749
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are "JSP UI fields"? Using JSP generally implies a web browser client - that would mean generating HTML; is that what you intend to do?
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to implement the jsp in the client side which is user friendly i.e it need to have 3*3 button for 2 users/players .My concern is how to integrate the jsp buttons or any fields to the code i have implemented in webservice(as i have posted)

I am a new bee..please help !!!
 
Tim Moores
Bartender
Posts: 2749
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is a server-side technology for creating textual output; in your case that would be HTML. I'd start by changing your code so that it generates HTML instead of what it does now.

I see little benefit in using a web service for this. I'd make every field which is not yet taken a button that submits a form to the server; it would update its internal state (probably kept in a session), and generate a new HTML page that reflects your move (and possibly the computer's move if you intend this to be a player-vs-computer game instead of a one-player-against-another-player game).
 
Navya J Nair
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okie
So , 1st I need to build the 3*3 grid using html (probably using table) i.e in jsp which is client side and then start coding each function like makeMove(), getWinner() in web-service part .
Please correct me if I am wrong.

Thanks Tim and would please suggest a good tutorial on web-services


 
Tim Moores
Bartender
Posts: 2749
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some starting points can be found at http://www.coderanch.com/how-to/java/WebServicesFaq
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic