Comp2513 Java Server Pages Daniel L. Silver, Ph.D.

Slides:



Advertisements
Similar presentations
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.
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.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Languages for Dynamic Web Documents
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
DT228/3 Web Development JSP: Directives and Scripting elements.
Java Server Pages B.Ramamurthy. Java Server Pages Servlets are pure Java programs. They introduce dynamism into web pages by using programmatic content.
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,
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Introduction to Servlet & JSP
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Comp2513 E-Commerce Infrastructure 2 Daniel L. Silver, Ph.D.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems JavaServer Pages (JSP)
JavaServer Pages TM Introduce by
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
UNIT-V The MVC architecture and Struts Framework.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
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.
Netbeans – jsp.zip Introduction to JSP Netbeans – jsp.zip.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
CIS 285 ROBINSON WINTER 2005 CIS 285 Web Application Development with Java CIS 285 Sinclair Community College Instructor: Mary Robinson.
JSP Java Server Pages Softsmith Infotech.
Introduction to Java Server Pages (JSPs) Robert Thornton.
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.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
Comp2513 JavaBeans, EJB and J2EE Daniel L. Silver, Ph.D.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
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.
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,
Chapter 10 Overview of JSP Technology. Understanding the need for JSP JSP technology enables to mix regular, static HTML with dynamically generated content.
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.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
MC365 Application Servers, Servlets, and Java Server Pages (JSP’s): Tomcat.
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.
Java Server Pages (JSP)
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
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.
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.
Java Server Pages Can web pages be created specially for each user?
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.
Scripted Page Web App Development (Java Server Pages)
MSIS 655 Advanced Business Applications Programming
Java Server Pages.
Java Server Pages (JSP)
Java Server Pages B.Ramamurthy.
Presentation transcript:

Comp2513 Java Server Pages Daniel L. Silver, Ph.D.

2001Daniel L. Silver2 Objectives Introduce Java Server Pages and their advantages over Servlets Introduce Java Server Pages and their advantages over Servlets To understand how JSPs work: The JSP Operational Model To understand how JSPs work: The JSP Operational Model To understand the basic components of JSPs To understand the basic components of JSPs To understand how JSPs work with Java Beans To understand how JSPs work with Java Beans Review examples of JSPs Review examples of JSPs –Web Reference: »JSP Intro JSP IntroJSP Intro »Servlet and JSP Programming with IBM Websphere – Ch. 5 Servlet and JSP Programming with IBM WebsphereServlet and JSP Programming with IBM Websphere –Paper Reference: EJP – Chapter 10

2001Daniel L. Silver3 The Problems With Java Servlets The presentation code (HTML) and business logic are closely coupled within java servlet The presentation code (HTML) and business logic are closely coupled within java servlet Large amount of source code required to display simple HTML of web-page Large amount of source code required to display simple HTML of web-page If HTML presentation needs to be changed then servlet source code must be modified If HTML presentation needs to be changed then servlet source code must be modified If business logic needs to be changed then it must be found within the mix of HTML and Java If business logic needs to be changed then it must be found within the mix of HTML and Java E-Commerce Web developers are typically not Java programmers and visa versa E-Commerce Web developers are typically not Java programmers and visa versa

2001Daniel L. Silver4 JSPs – Java Server Pages JSPs – a relatively new Java programming model from SUN (similar to Netscape Server-side Javascript and MS Active Server Pages, but more powerful) JSPs – a relatively new Java programming model from SUN (similar to Netscape Server-side Javascript and MS Active Server Pages, but more powerful) Developed to separate the dynamic content (Java) of pages from the more static HTML content Developed to separate the dynamic content (Java) of pages from the more static HTML content I.E.: application processing (business logic) code from the HTML presentation code I.E.: application processing (business logic) code from the HTML presentation code Looks like HTML but allows execution of Java* within the HTML file or access to component objects (Java Beans) Looks like HTML but allows execution of Java* within the HTML file or access to component objects (Java Beans) * the specification allows for coding/scripting languages other than Java

2001Daniel L. Silver5 Skeleton of a JSP <HTML><HEAD> HelloJSP1 HelloJSP1 </HEAD><BODY> Hello JSP - Example 1 Hello JSP - Example 1 <jsp:useBean id="textProvider" id="textProvider" class="exampleBean.HelloJSP1" class="exampleBean.HelloJSP1" scope="request"> scope="request"></jsp:useBean> </BODY></HTML> Standard HTML Code Java Object Created from a JavaBean Calling a method of the Java Object Special JSP Tags

2001Daniel L. Silver6 How useful are JSPs? Web page developers design and create the web-pages, incorporating styles and aesthetics. (Presentation Layer) The dynamic content is left to the Java code. Web page developers design and create the web-pages, incorporating styles and aesthetics. (Presentation Layer) The dynamic content is left to the Java code. The JSP file can call other servlets and perform the business logic features of the site. The Java programmer can concentrate on the functionality (Application Layer) of the web site. The JSP file can call other servlets and perform the business logic features of the site. The Java programmer can concentrate on the functionality (Application Layer) of the web site.

2001Daniel L. Silver7 Advantages of JSPs Separation of dynamic and static content Separation of dynamic and static content –Web developer creates and maintains the HTML content –Java programmer creates and maintains dynamic content and business logic Platform independence Platform independence –Standards promote portability (but …beware) Component reuse Component reuse –Promotes the use of JavaBeans and Enterprise JavaBeans –Speeds up website development and support

2001Daniel L. Silver8 Advantage of JSPs Scriptlets and Tags Scriptlets and Tags –JSP Scriptlets »Small pieces of Java code embedded directly in HTML –JSP Tags »Provide an easy way to embed and modify JavaBean properties for specific use »Issue JSP directives and other actions

2001Daniel L. Silver9 The JSP Operational Model 1. HTTP server receives request for.jsp file 2. The.jsp file is located (can be in any directory) 3. Tomcat is called and passed the.jsp file 4. Tomcat invokes a special servlet called pageCompile (the JSP engine, comes as part of JSP distribution) 5. pageCompile builds a servlet based on JSP code (that may include a reference to a JavaBean) 6. The servlet.java and.class files are written to disk (internal to Tomcat) 7. The.class file is processed by the JVM within Tomcat like any other servlet 8. HTML code is generated by the servlet and returned

2001Daniel L. Silver10 Tomcat Java Servlet Request Processing Internet Browser Client HTTP Server HelloWorld.jsp mod_jserv Tomcat App. Server../Store05/HelloWorld.jsp HTML HelloJSP1.class../Store05/WEB-INF/classes/exampleBean/HelloJSP1 HelloWorld.java HelloWorld.class pageCompile

2001Daniel L. Silver11 Components of JSPs JSP are composed of standard HTML tags and JSP tags JSP are composed of standard HTML tags and JSP tags The standard set of JSP tags can be categorized as follows: The standard set of JSP tags can be categorized as follows: –Comments –Directives –Declarations –Scriptlets –Expressions

2001Daniel L. Silver12 JSP Comments HTML comment will appear in the output stream to the browser HTML comment will appear in the output stream to the browser JSP comment will not be processed by the JSP compiler JSP comment will not be processed by the JSP compiler

2001Daniel L. Silver13 Directives JSP directive is a global definition for the JSP engine (compiler) that normally appears at the top of the JSP page JSP directive is a global definition for the JSP engine (compiler) that normally appears at the top of the JSP page Page directive Page directive Include directive Include directive

2001Daniel L. Silver14 Declarations A declaration block defines Java variables and methods that are accessible to other code within the page (such as an expression block) A declaration block defines Java variables and methods that are accessible to other code within the page (such as an expression block) Example: Example:<%! private int getDateCount = 0; private String getDate(GergorianCalendar gcl) { …. method code …}; %>

2001Daniel L. Silver15 Expressions An expression is a scriptlet fragment that produces a result & emits it as String object. An expression is a scriptlet fragment that produces a result & emits it as String object. Used to generate dynamic text, prevents having to use println() statements Used to generate dynamic text, prevents having to use println() statements Example: Example:

2001Daniel L. Silver16 JSP Scriptlets Java code fragments can be embedded within a JSP to provide small pieces of logic that dynamically manipulate HTML and do not warrant creation of a JavaBean Java code fragments can be embedded within a JSP to provide small pieces of logic that dynamically manipulate HTML and do not warrant creation of a JavaBean Example: Example: <% if (Calendar_Time.AM_PM== Calendar.AM) { %> { %> How are you this morning, How are you this morning, How are you this afternoon, How are you this afternoon,

2001Daniel L. Silver17 Access to Implicit Objects When writing scriptlets or expressions there is often a need to access standard Java objects: When writing scriptlets or expressions there is often a need to access standard Java objects: –request - access to request object »Example of use: request.getParemeter() –response – access to response object »Example of use: response.setHeader() –out – output stream writer »Example of use: out.println()

2001Daniel L. Silver18 Putting it all Together DateDisplay is a basic JSP that you can begin to learn from DateDisplay is a basic JSP that you can begin to learn from DateDisplay is DateDisplay is Here is a link to the JSP source (view in source mode) Here is a link to the JSP source (view in source mode)JSP sourceJSP source Here is a link to the Java source resulting from the JSP compilation Here is a link to the Java source resulting from the JSP compilationJava sourceJava source

THE END