Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Servlet -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica.

Similar presentations


Presentation on theme: "Java Servlet -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica."— Presentation transcript:

1 Java Servlet -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica

2 - Write a Servlet that writes Hello Client! when it is called HelloWorld

3 Write a servlet-based application composed of the following client and server components: 1. Client-component - An HTML page with an HTML form that contains three text fields and a submit button. The button uses the GET method to send its data to the server-component. 2. Server-component - A servlet that takes the three inputs submitted via GET by the Form and it builds a dynamic HTML page (its title will be Reading Three Request Parameters) that contains a string composed of the value of the three inputs Servlet and Form

4 TESTING Implemented functionality: Client pageservlet dynamically-built HTML page - params1,2,3 - page title - params1,2,3

5 Servlet and Form, change requirements Implement the following change requirements: 1. In the client-component: - add another form that sends to the server-components the same set of data of of the implemented form but using the POST method; - migrate the HTML implementation of the client component into a servlet-based implementation (i.e., a servlet that dynamically generates the same HTML page). 2. In the server-component: - add the treatment of the new three POST-based set of inputs. Please, do not develop software clones (between doGet and doPost), but extract the shared part of the code; - set the title of the built HTML page according to the type of method used to receive the data from the form (i.e., insert GET or POST in the title) - wrap all the servlet in a package named servletForm

6 TESTING Implemented functionality: Dynamically-built HTML page 1 Servlet 2 dynamically-built HTML page GET(params1,2,3) - page title (GET|POST) - params1+2+3 Servlet 1 POST(params1,2,3)

7 Write a servlet-based application that simulates a system used to register the course marks for a student. In particular: 1. index.html - it is composed of a form that contains three fields (text: name and surname; number: id) and a submit button - it submits those data to the Welcome servlet using the GET method 2. Welcome servlet - it reads the three inputs submitted via GET by the index.html page - it creates a session object (instance of a Java class) - it stores the received data in that new session object - it builds an HTML page that contains: session ID, name and surname of the student three links: (i) to the index.html page; (ii) to the Exit servlet; and (iii) to the marks.html page StudentMarks Simulation, the first Servlet-based Application

8 3. Exit servlet - it gets the session object - it close both the session and the application - it builds and HTML page that contains the string Bye Bye and the ID of the closed session 4. marks.html - it is composed of a form that contains four text fields (text: courseName1/2 and number: courseMark1/2) and a submitt button - it submits those data to the SetMarks servlet using the GET method 5. SetMarks servlet - it gets the session object - it reads the four inputs submitted via GET by the form in the marks.html - it stores in the session object those data - it builds an HTML page that contains: the session ID, name and surname of the student, the average value of the courseMark1/2 inputs stored in the session object a link to the Exit servlet StudentMarks Simulation, the first Servlet-based Application (2)

9 For the implementation see the Eclipse project... StudentMarkSimulation StudentMarks Simulation, the first Servlet-based Application (3)


Download ppt "Java Servlet -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica."

Similar presentations


Ads by Google