CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems JavaServer Pages (JSP)

Slides:



Advertisements
Similar presentations
Michelle Johnston, Firebird Services Ltd
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Java Server Pages (JSP)
Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
DT211/3 Internet Application Development
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
DT228/3 Web Development JSP: Directives and Scripting elements.
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,
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
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.
Eclipse is an open source IDE (Integrated Development Environment) for developing applications in Java, C/C++, HTML, Cobol, Perl, etc. The official Eclipse.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 37 - JavaServer Pages (JSP): Bonus for Java Developers Outline 37.1 Introduction 37.2 JavaServer.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
JSP Java Server Pages Softsmith Infotech.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Jordan Anastasiade. All rights reserved.
 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,
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.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Chapter 7 Being a JSP. JSP introduction JSP is a solution for two issues  Servlet is difficult for HTML designers since they may not know Java  Formatting.
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.
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.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Core basic Java web server technologies. Tools Eclipse IDE for Java EE Developers (Netbeans also works) nloads/packages/eclipse-
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
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.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
JAVA SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra.
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.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
JSP / Servlets and Beans
5 Copyright © 2004, Oracle. All rights reserved. PL/SQL Server Pages.
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
JSP java server pages.
CS122B: Projects in Databases and Web Applications Spring 2017
CS122B: Projects in Databases and Web Applications Winter 2017
JSP Based on
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.
MSIS 655 Advanced Business Applications Programming
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems JavaServer Pages (JSP) - Lab 4 -

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 2 What Is JSP?  JSP  Java Server Page  SUN’s solution to both CGI and ASP  Java version of ASP  a Web page with Java code embedded inside it that runs on the Web server  JSP source code runs on the web server in the JSP engine. The JSP engine dynamically generates the HTML and sends the HTML output to the web browser

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 3 JSP vs. ASP  Fairly similar in the functionality  A web page with code embedded inside it that runs on the Web server  ASP-- only on Microsoft platforms, JSP -- on any platform that conforms to the J2EE specification

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 4 JSP vs. Servlet  both are Sun’s technology and have many features in common  both can be used for generating dynamic web content  Servlet -- Java class that provides special server side service, JSP -- HTML page with embedded code  all JSPs eventually become servlets before executing

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 5 Why Use JSP?  separation of static from dynamic content (different from Servlet)  Write Once Run Anywhere  completely leverages the Servlet API

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 6 JSP Architecture

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 7 JSP Lifecycle JSP initialization  run JspInit method  JSP execution  run _jspService (HttpServletRequest, HttpServletResponse) method  JSP cleanup  run JspDestroy method  JSP loading JSP compilation (if it has not yet been compiled)

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 8 Your First JSP Welcome to CMPUT391 Lab!  Store the file in the your JSP directory: YourHomeDirectory/catalina/webapps/proj1  Load the new file, with the ".jsp" extension, in your browser

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 9 Adding Dynamic Content via Expressions  The ability to embed Java  to embed Java expressions in JSP pages put them within the Expression tag: Hello! The time is now

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 10 Scriptlets  Scriptlet: a block of Java code inside JSP  Executed every time JSP is invoked  to create a scriplet, place your Java code within the tag (just like Expression tag, but without the = sign at the start of the sequence)

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 11 Scriptlets: Example <% // This is a scriptlet. Notice that the "date" // variable we declare here is available in the // embedded expression later on. java.util.Date date = new java.util.Date(); %> Hello! The time is now

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 12 Generating HTML in Scriplets  A scriptlet does not generate HTML by itself (unlike an Expression tag)  Use a variable called "out".  NO need to declare (already predefined for scriptlets)

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 13 Generating HTML in Scriplets: Example <% // This scriptlet declares and initializes "date" java.util.Date date = new java.util.Date(); %> Hello! The time is now <% // This scriptlet generates HTML output out.println(String.valueOf(date)); %>

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 14 Pre-defined Objects for JSPs  there are several objects that are automatically available in JSP: VariableType requestJavax.servlet.http.HttpServletRequest responseJavax.servlet.http.HttpServletResponse outJavax.servlet.jsp.JspWriter sessionJavax.servlet.http.httpsession pageContentJavax.servlet.jsp.pagecontext applicationJavax.servlet.http.ServletContext configJavax.servlet.http.ServletConfig pageJava.lang.Object

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 15 Mixing Scriptlets and HTML Number

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 16 JSP Directives Hello! The time is now

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 17 JSP Directives (cont.)  a JSP directive gives special information about the page to the JSP Engine.  directive tag:  there are three main types of directives: –page - processing information for this page List of imported packages: –include - files to be included –tag library - tag library to be used in this page.

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 18 JSP Directives: Include (Example) Going to include another.jsp …

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 19 JSP Declarations  for a JSP, all the code within the tags and all the expressions within the tags belong to one big Java method in the generated servlet  a JSP declaration is used to enclosed any declarations that belong outside the big method that generates the page  declaration tag:

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 20 JSP Declarations: Example <%! Date theDate = new Date(); Date getDate() { System.out.println( "In getDate() method" ); return theDate; } %> Hello! The time is now

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 21 Inserting Comments into JSPs  If your JSP is generating HTML, you can use HTML comments:  Java one-line comment:  Java multi-liners comments: …

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 22 Processing a Form with JSP Enter a test string: JSPExample8.html Your info has been received: <% String sName = request.getParameter(“test"); out.print(sName); %> JSPExample8.jsp

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 23 Summary  JSPs are eventually turned into Servlets  though JSPs are much simpler than servlets, for some cases Servlets are still useful  one could combine JSP and Servlet in one project

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 24 Further Readings  other JSP tutorials: – onlineTraining/JSPIntro/ – Tutorial/  JSP specifications: –

Lab 4 JavaServer Pages CMPUT 391 – Database Management Systems 25 Exercise  create and populate a table in your Oracle account (At least 2 columns & 4 records)  Only use JSP, implement: –connect to Oracle database –execute the SQLStatement received from the browser (e.g. select * from “table name”;) –display ResultSet (including column labels) & format the output (i.e. align the columns. Tip: use ResultSetMetaData & “Table” tag in HTML) –display an error if the SQL statement was not executed correctly in Oracle (e.g. select * from “wrong table”)