1 Web Applications – The Basics (Part 2). 2

Slides:



Advertisements
Similar presentations
Servlets, JSP and JavaBeans Joshua Scotton.  Getting Started  Servlets  JSP  JavaBeans  MVC  Conclusion.
Advertisements

Apache Tomcat as a container for Servlets and JSP
Java Server Pages (JSP)
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
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.
CSE 190: Internet E-Commerce Lecture 7. HTML Templates Designed to separate server side logic from HTML presentation Key features –Escapes from HTML into.
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.
1 Web Applications – The Basics. 2 Unzipped Tomcat Folder.
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,
Three types of scripting elements: 1.Expressions 2.Scriptlets 3.Declarations Scripting elements.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
CSCI 6962: Server-side Design and Programming History and Background.
Servlet and JSP Programming: An Introduction Spiros Papadimitriou
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
1 Guide to JSP common functions 1.Including the libraries as per a Java class, e.g. not having to refer to java.util.Date 2.Accessing & using external.
Introduction Servlets and JSP Celsina Bignoli
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
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.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
Java Servlets. Servlets When we run small Java programs within a browser these are referred to as Applets... And when we run small Java programs within.
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.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
Top right corner for field-mark, customer or partner logotypes. See Best practice for example. Slide title 40 pt Slide subtitle 24 pt Text 24 pt Bullets.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
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.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
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.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
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.
Ajax and the GWT. Ajax  Asynchronous JavaScript And XML  Technology behind interactive web sites  Provide smoother experience than conventional web.
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java and the Web CSE 3330 Southern Methodist University.
Java Servlets and Java Server Pages
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
SKT-SSU IT Training Center Servlet and JSP. Chapter Eleven: Invoking Java Code with JSP Scripting Elements.
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,
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
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.
Georgia Institute of Technology Making Text for the Web part 2 Barb Ericson Georgia Institute of Technology March 2006.
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.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
JSP java server pages.
Introduction to Servlets
JSP Based on
Principles of Software Development
Building Web Apps with Servlets
Developing JavaServer Pages
In Class Assg 3 - Solution
Java Server Pages.
Jagdish Gangolly State University of New York at Albany
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
null, true, and false are also reserved.
Conditional Statements
In Class Assg 2 - solution
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

1 Web Applications – The Basics (Part 2)

2

3 Webapps/abc/j1.jsp Hello! The time is now

4 JSP An External DSL for generating HTML Server: –Generates Java code off of it –Compiles –Runs Has extensions (Tag-libraries)

5 Java Blocks <% System.out.println( "Evaluating date now" ); java.util.Date date = new java.util.Date(); %> Hello! The time is now <% out.println( date ); out.println( " Your machine's address is " ); out.println( request.getRemoteHost()); %>

6

7 Webapps/abc/j2.jsp <% int i = 0; while(i < 10) { %> i= <% ++i; } %>

8 Velocity: An Example Hello $customer.Name! #foreach( $mud in $mudsOnSpecial ) #if ( $customer.hasPurchased($mud) ) $flogger.getPromo( $mud ) #end

9 Velocity: Binding Data Customer customer = Database.retrieveByPK(primaryKey); context.put("customer", customer); List mudsOnSpecial = Database.selectSpecialMuds(); context.put("mudsOnSpecial", mudsOnSpecial);

10 Internal DSL: XMLBuilder (Ruby) require 'xmlbuilder' data = {'Coffee' => 'Pot', 'Saw' => 'Mill', 'Christmas' => 'Jam'} xml.html do head do title { 'Test Page' } end body do table :width => 500 do data.each do |key, value| tr do td { key } td { value } end element :p do "some text" end element :p do "Some other text" end end (By Daniel Spiewak,

11 f8.html

12 Ajax Asynchronous JavaScript and XML User Interacts with the page Javascript code communicates with the server –(In the background) When a response arrives – Page is updated Note: Data does not have to be XML-ed

13 webapps/abc/f8.html Team Name: Suggestion: $(document).ready(function() { var element = $("#input"); element.keyup(function() { var params = {}; params.url = "d3.html"; params.data = 'input=' + $("#input").val(); params.dataType = 'json'; params.type = 'get'; params.success = function(items) { var bullets = " "; for(var i = 0; i < items.length; ++i) bullets += " " + items[i] + " "; bullets += " "; $("#suggestion").html(bullets); }; $.ajax(params); });

14 Source code: S3.java package s1; public class S3 extends HttpServlet { private static final long serialVersionUID = L; private static List teams = Arrays.asList("Australia", "Japan",... protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("application/json"); resp.setCharacterEncoding("UTF-8"); String in = req.getParameter("input"); String result = process(in); resp.getWriter().println(result); } private String process(String in) { List matches = computeMatches(in); Collections.sort(matches); return computeOutput(matches); }

15 Source code: S3.java (cont.) package s1; public class S3 extends HttpServlet {... private String computeOutput(List matches) { if(matches.size() == 0) return "[]"; String result = "[" + matches.get(0).quote(); for(int i = 1; i < matches.size(); ++i) { if(matches.get(i-1).compareTo(matches.get(i)) != 0) break; result += ", " + matches.get(i).quote(); } result += "]"; return result; }

16 Source code: Match.java public class Match implements Comparable { public String team; public int charCount = 0; public Match(String team, String keyword) { this.team = team; if(keyword == null) return; Set s1 = Match.setOf(team); Set s2 = Match.setOf(keyword); s1.retainAll(s2); this.charCount = s1.size(); } public String quote() { return "\"" + team + "\""; public int compareTo(Match that) { return that.charCount - charCount; } private static Set setOf(String s) { s = s.toLowerCase(); HashSet result = new HashSet (); for(int i = 0; i < s.length(); ++i) result.add(s.charAt(i)); return result; }