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

Slides:



Advertisements
Similar presentations
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
Advertisements

An introduction to Java Servlet
Servlet-JSP and HtmlFixture exercise and solution
1 Web Applications development and testing Alessandro Marchetto Fondazione Bruno Kessler-IRST,
JSP -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Java Server Pages (JSP)
Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets and a little bit of Web Services Russell Beale.
CS320 Web and Internet Programming JSP Scripting Elements and Page Directives Chengyu Sun California State University, Los Angeles.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Web applications: HTML and Client-side code.
1 Static Web Pages Websites on Servers (The Big Picture) –Apache Tomcat can support static web pages –Primarily intended to support servlets and JSP –Some.
1 Web Search Interfaces. 2 Web Search Interface Web search engines of course need a web-based interface. Search page must accept a query string and submit.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
All You Ever Wanted To Know About Servlets But Were Afraid to Ask.
Server Side Programming Web Information Systems 2012.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
CSCI 6962: Server-side Design and Programming History and Background.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
ASHIMA KALRA.  INTRODUCTION TO JSP INTRODUCTION TO JSP  IMPLICIT OBJECTS IMPLICIT OBJECTS  COOKIES COOKIES.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Sviluppo di applicazioni web Servlet
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
JSP Java Server Pages Softsmith Infotech.
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
SKT-SSU IT Training Center Servlet and JSP. Chapter Three: Servlet Basics.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Inside the WebApp Classes John Tuohy Data Access Worldwide.
Standalone Java Application vs. Java Web Application
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
Java Servlets example using NetBeans 6. Pre-requirements: Install Java JDK 1.6 Install NetBeans IDE 6 (we will use version NetBeans IDE update 16)
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Session tracking There are a number of problems that arise from the fact that HTTP is a "stateless" protocol. In particular, when you are doing on- line.
Chapter 6 Server-side Programming: Java Servlets
Jsp (Java Server Page) Is a server side program.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
All You Ever Wanted To Know About Servlets But Were Afraid to Ask.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
Field Trip #24 Setting Up a Web Server. Apache Apache is one of the most successful open source web servers In 1995 the most popular web server was the.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Labs: Create, deploy and test a simple web service
Introduction to Servlets
Servlets.
Chapter 6 Server-side Programming: Java Servlets
Chapter 26 Servlets.
Session Tracking Techniques
J2EE Lecture 1:Servlet and JSP
Please insert Title Please insert sub-title 1
Presentation transcript:

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

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

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

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

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

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)

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

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)

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