Servlet-JSP and HtmlFixture exercise and solution

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

1 Web Applications development and testing Alessandro Marchetto Fondazione Bruno Kessler-IRST,
14/03/07 Change requirements with FIT/FitNesse 1 Ceccato Mariano ITC-Irst Trento, Italy
JSP -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica.
Java Servlet -exercises- Alessandro Marchetto Fondazione Bruno Kessler-IRST, Centro per la Ricerca Scientifica e Tecnologica.
Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Struts Portlet Adding an Action Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
JSF Portlet Backing Beans and UI Components Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in.
Short Portlet Programming Guide in P-Grade (Gridsphere) environment G. Hermann.
Development Configuration Guide Using NetBeans IDE
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Web MVC-2: Apache Struts Rimon Mikhaiel
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
Java Integrated Development Environments: ECLIPSE Part1 Installation.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Contrast with JavaScript HTML Formsto invoke Java Server Pages Structure of Forms Query strings Java Server Pages Sent From Browser To Serverfor JSP.
Create a New Application and Project Open the Create Application dialog. Enter the application name of your choice and the directory. Select No Template.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Servlet and Tomcat Tutorial
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
JSP and Servlets Lecture notes by Theodoros Anagnostopoulos.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
INTERNET APPLICATION DEVELOPMENT For More visit:
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 29.1 Multi-Tier Architecture 29.2 Web Servers.
Web Technologies Website Development Trade & Industrial Education
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
JSP Java Server Pages Softsmith Infotech.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
LLRP GUI Client User Guide
Plug-in Development Environment. Session Outline Tools Installation Configuration New Project Basic Debugging Remote Debugging.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
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.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
HTML Basics BCIS 3680 Enterprise Programming. Web Client/Server Architecture 2  Your browser (the client) requests a Web page from a remote computer.
PHP Form Introduction Getting User Information Text Input.
Jsp (Java Server Page) Is a server side program.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
DEVS M&S Tutorial with eclipse IDE Chungman Seo
1 Introduction to Web Applications & APIs. 2 Agenda  Architecture of Web Applications Three layer architecture  Web Server (Tomcat) Installation Data.
OOSSE Week 8 JSP models Format of lecture: Assignment context JSP models JSPs calling other JSPs i.e. breaking up work Parameter passing JSPs with Add.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
JSP Server Integrated with Oracle8i Project2, CMSC691X Summer02 Ching-li Peng Ying Zhang.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
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.
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.
Session: 4. © Aptech Ltd. 2Creating Hyperlinks and Anchors / Session 4  Describe hyperlinks  Explain absolute and relative paths  Explain how to hyperlink.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Labs: Create, deploy and test a simple web service
Play Framework: Introduction
JavaTeaching and Importing a github repository
Add Image and Title to Individual Page
Installing Tomcat.
Search for Manage Procurement Agents task in the Setup and Maintenance work area, Procurement offering, Procurement Foundation functional area. Select.
Presentation transcript:

Servlet-JSP and HtmlFixture exercise and solution Alessandro Marchetto

Exercise: NameWeb, four tasks: a) testing b) bug fixing c) maintenance d) evolution

Note - Download fitnesse.zip - Unzip it into the desktop http://selab.fbk.ru/marchetto/software/fitnesseImproved.zip - Unzip it into the desktop - Take a note of the directory path

Steps Download the zip file “NameWeb.zip” and put it in the desktop http://selab.fbk.eu/marchetto/exercise/exe_testing/NameWeb.zip 1. Import it into Eclipse FileImport”Existing Project into Workshopace” and click “next”  select “Archive File”  Browser your desktop to select the “exercise1.zip”  click “Finish” 2. In the new Eclipse project: -- (if needed) create a directory called "work" if it doesn't exist -- (if needed) delete subdirectories of  the directory "work" if it exist and contains errors -- (if needed) Start Tomcat or restart it -- open the "Tomcat project" menu (right-button mouse in the project) and update the Tomcat context

3. Start Fitnesse for the imported project (named nameWeb) -- remember to modify the classpath with the path of the fitnesse.zip in your desktop !path C:/…/fitnesseImproved/lib/*.jar 4. Execute the tasks described in wiki page: a) write Fit tables b) bug fixing c) maintenance d) evolution

The NameWeb application NameWeb is composed of: 1. A client side page named index.html it contains a form composed of 2 text fields (name and surname) and a submit button the form sends its data to the JSP page 2. A JSP page named nameWeb.jsp it gets name and surname sent by the client - it stores name and surname in a JavaBean it reads the data stored in the JavaBean it writes in output a string such as “Welcome: name surname” 3. A JavaBean named beanPck.NameBean it defines a field of type string it contains two methods used to set/get the string

NameWeb –JSP and Form – (1) index.html Please, insert the requested data for JSP: <br> <form method="get" action="nameWeb.jsp" > Name: <input type="text" name="nameJ" /> <br /> Surname: <input type="text" name="surnameJ" /> <input type="submit" value="submitToJSP" /> </form>

NameWeb – Servlet, JSP and Form – (3) nameWeb.jsp <HTML> <HEAD> <TITLE> JSP for name and surname </TITLE> </HEAD> <BODY> <P> <jsp:useBean id="beanN" class="beanPck.NameBean" /> <% String name=request.getParameter("nameJ"); String surname=request.getParameter("surnameJ"); beanN.setContent(name, surname); %> <H1>Welcome: <I> <% String content=beanN.getContent(); out.println(content); %> </I> </H1> </BODY> </HTML>

NameWeb – Servlet, JSP and Form – (5) beanPck.NameBean package beanPck; public class NameBean { private String content="anonymous"; public String getContent() { return(content); } public void setContent(String name, String surname) { content=name+surname;

The Fitnesse-wiki contained in the Eclipse project to do these tasks: 1) Testing Write a test-case using the HtmlFixture for testing the application... 2) Bug Fixing There is a bug in the main functionality of the NameWeb application. 3) Maintenance: Refactoring: extract in a function the code used to concatenate name and surname written in the form by the user 4) Evolution: Add a field “nation” in the form so that the new output will be such as: “Welcome: name surname from nation” instead of “Welcome: name surname”

1) Testing: Write a test-case using the HtmlFixture for testing the application as follows: A) - call the index.html - verify that the page does not contain/define a title - verify if the name of the “Surname” field of the HTML form is “surnameJ” (note that it is an attribute of the element input) - verify how many input of type submit are contained in the page - verify that only 1 form element is contained in the page B) call the page index.html fill the form with “myName” and “mySurname” click the submit button verify if the title of the built page is “JSP for name and surname”

Test case (A) |!-com.jbergin.HtmlFixture-!| | http://localhost:8080/NameWeb/index.html | requestPage | ?

Test case (B) |!-com.jbergin.HtmlFixture-!| | http://localhost:8080/NameWeb/index.html | requestPage | ?

2) Bug fixing: There is a bug in the main functionality of the NameWeb application.

Test case !path fitnesse.jar !path *.jar !path lib/*.jar !path classes |!-com.jbergin.HtmlFixture-!| | http://localhost:8080/ex2/index.html | requestPage | | Focus | requestPage | | Element Focus | nameJ | input | textField1 | | Set Value | myName | | Element Focus | surnameJ | input | textField2 | | Set Value | mySurname | | Element Focus | f_jsp | form | | Submit | response1 | | Focus | response1 | | Has Text | Welcome: myName mySurname | Test case

JavaBean Before and After bug-fixing

3) Maintenance: Refactoring: extract in a function the code used to concatenate name and surname written in the form by the user

Test case !path fitnesse.jar !path *.jar !path lib/*.jar !path classes |!-com.jbergin.HtmlFixture-!| | http://localhost:8080/ex2/index.html | requestPage | | Focus | requestPage | | Element Focus | nameJ | input | textField1 | | Set Value | myName | | Element Focus | surnameJ | input | textField2 | | Set Value | mySurname | | Element Focus | f_jsp | form | | Submit | response1 | | Focus | response1 | | Has Text | Welcome: myName mySurname | Test case

JavaBean Before and After the task

beanPck.NameBean package beanPck; public class NameBean { private String content="anonymous"; public String getContent() { return(content); } public void setContent(String name, String surname) { content=concatenate(name, surname); public String concatenate(String name, String surname){ return name+" "+surname;

4) Evolution: Add a field “nation” in the Form so that the new output will be such as: “Welcome: name surname from nation” instead of “Welcome: name surname”

Test case !path fitnesse.jar !path *.jar !path lib/*.jar !path classes |!-com.jbergin.HtmlFixture-!| | http://localhost:8080/ex2/indexEvolution.html | requestPage | | Focus | requestPage | | Element Focus | nameJ | input | textField1 | | Set Value | myName | | Element Focus | surnameJ | input | textField2 | | Set Value | mySurname | | Element Focus | nationJ | input | textField3 | | Set Value | myNation | | Element Focus | f_jsp | form | | Submit | response1 | | Focus | response1 | | Has Text | Welcome: myName mySurname from myNation |

Before the evolution

After the evolution