CSCI 6962: Server-side Design and Programming History and Background.

Slides:



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

Java Server Pages (JSP)
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.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
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.
An introduction to Java Servlet Programming
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
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.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets Life Cycle. The Servlet Life Cycle A servlet life cycle can be defined as the entire process from its creation till the destruction. The following.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets and JSP.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
JSP Java Server Pages Softsmith Infotech.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
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.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
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.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Writing Enterprise Applications with J2EE (Fourth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Servlets Part 3. Topics Session Tracking ServletToServletCommunication-Servlet Chaining ServerSideIncludes AppletToServlet.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
Chapter 11 Invoking Java Code with JSP Scripting Elements.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
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.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Vakgroep Informatietechnologie – Onderzoeksgroep (naam) Web Centric Design of Distributed Software.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Introduction To HTML Dr. Magdi AMER. HTML elements.
ClaRA web services V. Gyurjyan Clas12 Software Meeting
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 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.
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.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
S ERVLETS Form Data 19-Mar-16. F ORM P ROCESSING You must have come across many situations when you need to pass some information from your browser to.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Java Servlets References: Karen Anewalt, Mary Washington College.
Introduction to Servlets
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Presentation transcript:

CSCI 6962: Server-side Design and Programming History and Background

Overview Review of client/server architecture Previous approaches to server-side programming CGI-BIN Perl programming Web containers Java servlets Java Server Pages Limits to previous approaches 2

3 Client-Server Web Architecture Client Browser ~john/Syllabus.html Request to for Syllabus.html Server john  public_html port Response containing Syllabus.htm as a long string ( CSCI 6962 Syllabus …) Syllabus.html

4 Dynamic Form Handling Form data appended to request string Generates the request: <FORM NAME="purchaseform" METHOD=GET ACTION= bin/test.pl > bin/test.pl Quantity: /FORM>

5 Form Handling Server must: –Listen on port for requests –Parse request to determine values of parameters –Dynamically generate appropriate response page based on parameter values –Send response page back to client

6 Simple Form Elements The FORM tag … TEXT tag SUBMIT tag

Perl/CGI-Bin Request string manually parsed by code –Perl used because has built-in parsing procedures –String split on “&” and then on “=“ Response string manually generated –Based on data retrieved from request –Entire web page printed to response one html tag at a time 7

Simple perl cgi-bin Program #!/opt/local/bin/perl #program to print back results of test form #parse input string into an associative $ENV{'QUERY_STRING'}); foreach $pair $pair); $formdata{$key}=$value; } #print response to form print "Content-type: text/html\n\n"; print " cgi-bin response "; print "Thank you for your order of "; print $formdata{"quantity"}; print " widgets!"; print " ";

Java Servlets Java classes designed for server-side programming Constructed for and run by web container when request received –doGet and doPost methods called by web container –request object contains form data constructed from request by web container –request object built by servlet contains html for response page 9

10 Servlets and Web Containers Client Browser Web Container Port protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String quantity = request.getParameter("quantity"); try { out.println(" "); out.println(" Thank you for your order of " + quantity + " widgets! "); out.println(" "); } finally { out.close(); } Request object containing quantity = 3 Reesponse object containing html

11 Servlet Request Object Java object created from request string Contains request data and methods to access that data Most useful method: String request.getParameter(String) Data from form methods to access data Servlet code request Takes name of form element as parameter Returns the corresponding value passed to the server

Servlet Response Object Usual steps: PrintWriter out = request.getWriter gets link to response object out.println(html) writes text to response object 12

Basic Servlet Structure Key methods: void doGet(HttpServletRequest request, HttpServletResponse response) Called if servlet invoked using get method void doPost(HttpServletRequest request, HttpServletResponse response) Called if servlet invoked using post method Have access to request object

Example Servlet 14

15 Java Server Pages Html document with executable code interspersed When page requested: –Code executed –Html generated and inserted in its place –Final all html document sent back as response request for somepage.jsp Glassfish server somepage.jsp html html Java html Java html html html html Java html html resulting html page html html html

16 JSP Syntax Basic tag form: Simplest form: –Glassfish evaluates expression to get value –Inserts that value in place of expression in generated html page

17 JSP Simple Example Simple example: Two plus two is. Two plus two is 4. Java Server Page Resulting html Page evaluated to value of 4

18 Scriptlets Basic tag form: Executes code inside brackets without generating html –Set variables later used to generate html later –Store/access values in session/databases Two plus two is.

19 Scriptlets Two plus two is. Stores value of 4 in sum variable Value of 4 in sum used in this JSP Two plus two is 4. No html here

20 Example JSP

21 Acquiring Form Data Same syntax as servlets: request.getParameter Key idea: Server Pages implemented as servlet Server Page request Servlet translated to html Run to create response

22 Displaying Values in Response 5

Limits of Server Pages Sever pages very complex mix of html/Java if conditions or loops needed Simple example: Plural/singular response 23 Html displayed if condition true Html displayed if condition false