|Tecnologie Web L-A Anno Accademico 2007-2008 Laboratorio di Tecnologie Web Sviluppo di applicazioni web Servlet

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
DT228/3 Web Development WWW and Client server model.
Languages for Dynamic Web Documents
DT211/3 Internet Application Development JSP: Processing User input.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
Servlets and a little bit of Web Services Russell Beale.
Configuring web servers and web applications 1. 2 Server configuration vs. application configuration A web server may run several web application Server.
Session Management A290/A590, Fall /25/2014.
Tomcat Configuration A Very, Very, Very Brief Overview.
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.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Java web development Servlet & Java server pages.
Java Servlets and JSP.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
UNIT-V The MVC architecture and Struts Framework.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
Computer Concepts 2014 Chapter 7 The Web and .
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Applets & Servlets.
1 Servlet How can a HTML page, displayed using a browser, cause a program on a server to be executed?
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
JavaScript & jQuery the missing manual Chapter 11
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
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.
Introduction to J2EE Architecture Portions by Kunal Mehta.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Tutorial 10 Programming with JavaScript
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
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.
Chapter 6 Server-side Programming: Java Servlets
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Introduction to JavaScript CS101 Introduction to Computing.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
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.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
What is a Servlet? Java Program that runs in a Java web server and conforms to the servlet api. A program that uses class library that decodes and encodes.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
National College of Science & Information Technology.
Introduction to J2EE Architecture
Presentation transcript:

|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Sviluppo di applicazioni web Servlet Universita’ degli Studi di Bologna Facolta’ di Ingegneria

|Tecnologie Web L-A > From the course web site you can download an Eclipse project (TW0708.zip) resembling the course web site structure: Download it and import it as usual + set up environment.properties You can sniff scripts, styles and pages behaviour......or try do it better! Before we go on...

|Tecnologie Web L-A > The web.xml descriptor shows how to secure part of the site either via explicit login/error pages or popup forms (commented) by leveraging Tomcat users/roles, for the sake of simplicity (by now) Inside the course web site replica project: security

|Tecnologie Web L-A > There's a particular ANT build file (build-tunnel.xml) that runs a configurable tcp tunnel in a GUI (= monitor) mode. You can listen on port, say, 9999 and forward requests to 8080 Run the ANT target, browse to instead of and see what happenshttp://localhost: Inside the course web site replica project: ANT & tunnel

|Tecnologie Web L-A > Servlets are J2EE modular components that run on the server-side and process requests to programmatically generate dynamic responses > How to create a servlet Write code and descriptors (for instance within an Eclipse project) Add static resources (HTML pages, styles) and client-side scripts if needed Package all the stuff into a.war file Deploy it to the web server You can use the TemplateWebapp project as a starting point or the TemplateServlet one (with just some sample code inside, in addition, just to get you started immediately) Server-side code: servlets

|Tecnologie Web L-A > Tomcat provides, out-of-the-box, some servlet (and JSP) examples that can be useful to learn how to deal with Servlet's API and facilities Servlet examples \ You can invoke examples on or by following links on your Tomcat local home page Source code for the examples is partially accessible via web (through the example pages themselves) and completely available on you file system on $TOMCAT_HOME/webapps/servlet-examples

|Tecnologie Web L-A > The 'Request Info' servlet shows information about the request being handled > You can check request arguments and headers against the tunnel GUI For instance: request info (1/2)

|Tecnologie Web L-A > The 'screwdriver' link brings you to code's relevant excerpts > Alternatively, you can open the RequestInfoExample.java source file on your file system (path: $TOMCAT_HOME/webapps/servlets-examples/WEB-INF/classes) For instance: request info (2/2)

|Tecnologie Web L-A > Cookies are pieces of information, kept client-side > Each cookie is associated to the domain that has saved it > The 'Cookie Example' servlet shows how to handle cookies > The browser settings can show you the cookies in your browser For instance: cookies

|Tecnologie Web L-A > Session holds pieces of information, kept server-side > Clients can retrieve their sessions by means of session identifiers (kept in cookies or made available by rewriting URLs) For instance: session

|Tecnologie Web L-A > Do you remember what URL encoding provides for? The code shows it is generated by invoking response.encodeURL() Where to find more information? → Browse the API documentation!! For instance: searching for documentation (1/2) Try googling on method name!

|Tecnologie Web L-A > Besides, you can find a local copy of JEE API documentation on the course site For instance: searching for documentation (2/2)

|Tecnologie Web L-A > Download ValentineServlet.zip project from the course site and import it in Eclipse > This silly servlet computes the chances of... love affairs (..wrote it on Feb 14 th...) Valentine's servlet: project structure

|Tecnologie Web L-A > Just a sample servlet project: main page displays a form stylesheet provides for a 'lovely' layout form action invokes a servlet, by passing input field values as parameters javascript validates form on the client- side before performing the request servlet invokes a library function to compute results > Look at the project structure and find out elements! Valentine's servlet: elements

|Tecnologie Web L-A > web.xml descriptor maps ValentineServlet class to /valentine path by means of the servlet's Valentine name > servlet retrieves request parameters and invokes library functions to produce result > library is stored in the WEB-INF/lib/ path of the.war archive (note: Eclipse is not going to show it there, in the 'Package Explorer' view, because it's part of the build-path!!!) Valentine's servlet: servlet mapping

|Tecnologie Web L-A > I just can't stand typing all those “ ”, ”/”' and “\”” in the code so I wrote my own utility class (HTMLPrintWriter.java) that arranges tag strings on my behalf but you can just write out.println(“ Something ”); if it makes you fill more confortamble Valentine's servlet: not to mess up with output

|Tecnologie Web L-A > MyLibrary is the result of the 'package' target in the ANT build file of project TemplateLib (that you can download from the course web site and import in Eclipse) > It's just a simple (not webap) project like the TemplateApp one of class #1 > But... do I have to copy and paste manually that jar library in projects where I need it? Try to add a new ANT target do to that! you can copy delete, and copy tasks from the deploy-related targets of other projects you can add a popup message asking for the destination by copying from the target that runs the TcpTunnel and that's all Valentine's servlet: reusing libraries across projects

|Tecnologie Web L-A > MyLibrary.jar also contains a class to assemble declaration statements want to know how it works without looking at the code? try exporting the Javadoc to the /doc path in the TemplateLib project! > Try making your own servlet: use the TemplateServlet project as a structure skeleton for your project download the zip and import it in Eclipse change project name, project.properties (and build files' project name too, if you want to) and set up your environment.properties file a form that asks for name, surname, address, sex and a declaration javascript code that ensures name and surname fields are non-blank ones you can copy thst from the sample pages in CSSandJavascript.zip a servlet that processes the request by invoking library methods & returns results some styles to make things look pretty-good perhaps you can handle exceptions via web.xml mapping to error pages (see what happens if people from hell perform declarations...) Declaration servlet: it behaves the same

|Tecnologie Web L-A > DeclarationServlet sample project wil be online after the lab class... Declaration servlet: for instance...