40 likes | 137 Views
JSP -exercises-. Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica. JSP demo. Write a JSP application composed of: 1.An HTML page with a form that requests a string to the user (e.g., the name of the user) 2.A JSP page:
E N D
JSP -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica
JSP demo • Write a JSP application composed of: • 1.An HTML page with a form that requests a string to the user (e.g., the name of the user) • 2.A JSP page: • it reads the string sent by the client html • - it writes the string in a dynamically generated HTML page (that contains, e.g., “Welcome” + string) • - it writes in the generated HTML page also the current date (using java.util.Date)
Servlet, JSP and Form – Name application • Write a servlet and jsp based application as follows: • 1.Client • an HTML page with two Forms that contain two text fields (name and surname) and a submit button (that uses the GET method) • the first Form sends its data to a servlet • the other sends its data to a Jsp page • 2.A Servlet • it reads name and surname sent by the client (via GET) • and it writes a string such as “Welcome: namesurname” • 3.A JSP • - it reads name and surname sent by the client (via GET) • - it stores name and surname in a JavaBean • it reads the data stored in the JavaBean • it writes the stored data in the output using a string such as “Welcome: namesurname” • 4.JavaBean • - it defines a string and two methods to set/get the string
Java Bean -1 • Write a Jsp that uses a JavaBean as follows: • JavaBean • it defines a string and two methods to get value of the string and to set it (via parameter) • JSP • - it uses the JavaBean • it uses the “jsp:setProperty” in order to set the string-field of the Bean with the value “Hello Client!” • - it uses the “jsp:getProperty” in order to get the value of the string-field and write it on the output