Introduction to Java web programming Dr Jim Briggs JWP intro1.

Slides:



Advertisements
Similar presentations
JSP and web applications
Advertisements

CS4273: Distributed System Technologies and Programming I Lecture 11: JavaServer Pages (JSP)
Java Server Pages (JSP)
Apache Struts Technology
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
An introduction to Java Servlet Programming
DT211/3 Internet Application Development
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
DT228/3 Web Development JSP: Directives and Scripting elements.
Web programming for project students Dr Jim Briggs.
Apache Struts Technology A MVC Framework for Java Web Applications.
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.
Java Servlets and JSP.
Chapter 10 Servlets and Java Server Pages. A servlet is a Java class designed to be run in the context of a special servlet container An instance of the.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSP Java Server Pages Softsmith Infotech.
Introduction to Java Server Pages (JSPs) Robert Thornton.
Jordan Anastasiade. All rights reserved.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Deploying CFML on J2EE Servers Vince Bonfanti President New Atlanta Communications, LLC.
Standalone Java Application vs. Java Web Application
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
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.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
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 SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Fall CIS 764 Database Systems Design L8. Web ….
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
Chapter 7 Using Custom Tag Libraries and the JSP Standard Tag Library.
SE-2840 Dr. Mark L. Hornick 1 Java Server Pages. HTML/JSPs are intended to be used as the views in an MVC- based web application Model – represents an.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Java Server Pages (JSP)
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
CS-4220 Dr. Mark L. Hornick 1 Java Server Pages. HTML/JSPs are intended to be used as the views in an MVC- based web application Model – represents an.
Java Servlets and Java Server Pages Norman White Stern School of Business.
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
 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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Apache Struts Technology A MVC Framework for Java Web Applications.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
Developing JavaServer Pages
Knowledge Byte In this section, you will learn about:
Servlets and Java Server Pages
JavaServer Faces: The Fundamentals
J2EE Lecture 1:Servlet and JSP
Struts BY: Tejashri Udavant..
Presentation transcript:

Introduction to Java web programming Dr Jim Briggs JWP intro1

Java technology Concept of a Java Virtual Machine (JVM) Portability Three kinds of Java program –Applications –Applets –Servlets JWP intro2

Auxiliary server JWP intro3

Architecture of a Java web application JWP intro4

Servlet Mini program created when the servlet container first receives a request that maps onto it A servlet services a request via a thread Servlet object continues to exist until container closes down JWP intro5

Threads (digression) What's the output of this program? Thread t1 x = 7; print x; x = x + 1; print x; Thread t2 x = 12; print x; x = x – 3; print x; JWP intro6

Answers … and many more If your program depends on one of these being "correct", then you have a race condition bug JWP intro7

Typical functions of a servlet 1.Validate data input to it via HTTP request parameters 2.Perform some business function using that data 3.Decide what view the user should next see 4.Generate that view as an HTTP response JWP intro8

Servlet container Program that implements the Java servlet specification (and others) Part of the Java 2 Enterprise Edition (J2EE) Reference implementation used to be Tomcat (an Apache project: Full J2EE reference implementation now is Glassfish ( JWP intro9

Functions of servlet container 1.Listen for HTTP requests 2.Decode HTTP request and decide which application and servlet it is intended for 3.Call servlet, passing request and response objects 4.Encode HTTP response and send it JWP intro10

Mapping URLs to servlets Consider the URL: – Container must break this down – virtual hostwww.myserver.com –/myapp: context or web application –/myservlet: address within web application JWP intro11

JWP intro12

Web applications A container may run several (independent) web applications (webapps) Each must have a WEB-INF directory: –web.xml configuration file –classes directory –lib directory JWP intro13

Brief history of JWP Servlets JavaServer Pages (JSP) Various MVC technologies (including Apache Struts) JavaServer Faces (JSF) JWP intro14

JWP intro15 Important classes and interfaces 1 All servlets must implement the Servlet interface Class HttpServlet –init/destroy –doGet/doPut –Your servlet will derive from this

JWP intro16 Important classes and interfaces 2 2 parameters to a request handling method Class HttpServletRequest –String param = request.getParameter(name); Class HttpServletResponse –PrintWriter out = response.getWriter(); Class HttpSession –Holds data common to related requests

JWP intro17 JavaServer Pages (JSP) Distinction: –servlets: HTML embedded in program –JSP: program embedded in HTML JSP useful where majority of effort is page design Translated automatically into a servlet –Retranslated if changed (no need to restart server) Can be placed anywhere in a web application –but not visible to client if in the WEB-INF directory

JWP intro18 JSP elements Scriptlets Actions Directives Standard tags Custom tags Expression language

JWP intro19 Scriptlets Any Java code between Expressions – Declarations – DEPRECATED –Do not use - not XML –Much easier to use JSTL

JWP intro20 Actions Including other files – –Request time inclusion Accessing beans –

JWP intro21 Directives Page directive – Include directive – –Translation time inclusion

JWP intro22 Standard tags Java Standard Tag Library (JSTL) –Taglib directive –Core –SQL –XML –Format

JWP intro23 Custom tags Implement your own tags Create a Tag Library Definition (tld) file Extend predefined classes Specify your library in directive Use like JSTL tags

JWP intro24 Expression language Refer to Java Beans and other common classes ${expression} can appear as tag attributes or (since JSP 2.0) in the page itself Several implicit objects: –header ${header["user-agent"]} –param ${param['name']} ${param.name}

Deferred evaluation EL originally conceived as a read-only notation –${expression} reads value of property JSF (see later) also requires ability to update values EL therefore added deferred evaluation of expressions –Syntax: #{expression} JWP intro25