Jakob Nielsen
Jakob Nielsen

Reputation: 5198

Using Servlets, JSB and JavaBeans (MVC)

For an assignment in "Web Engineering" we have to use Servlets, Java Server Pages and Java Beans. (I know JSB is more or less deprecated, but we have to use it for training)

Basically we have a little dicing game. There is a road with 7 fields, you can click on a dice, after that you get a number between 1 - 3 and your car moves the number you diced. Then its the turn of the computer, until someone reaches the goal.

In the specification is stated that we have to use Java Bean for the model, JSP for the View and a Servlet for the Controller.

What we did already is that we have created a Java Bean which includes all the information of the players and the game (like round, time, leader). This information is shown with JSP.

What we cant figure out is how to use servlets. Basically with clicking on the dice, I guess it should open the servlet, but how can it than communicate with the JSP and the bean.

Maybe someone got an idea how to manage that properly?

Here a screenshot: http://gyazo.com/c5e5eaae2de23d20755d687c479dccce (it`s german)

The table on the top left ist dynamic and with each click on the dice it should change, as well as the car and the dice.

Upvotes: 1

Views: 2152

Answers (1)

Joshua
Joshua

Reputation: 222

So basically, when you click the dice. Your browser will preform some web action to a url. usually a POST or a GET. Listening on that URL you have a servlet. This servlet has a way of getting the data you have pushed when going to that URL. The servlet then does something, either loading up data by calling the model, or changing data. Then it redirects you to / loads the JSP with that Model. The jsp then shows the data from that Model. I hope that helps!

Upvotes: 2

Related Questions