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.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
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.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
 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.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
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.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
Java Server Pages B.Ramamurthy. Java Server Pages Servlets are pure Java programs. They introduce dynamism into web pages by using programmatic content.
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
1 CS6320 – JSP L. Grewe 2 Java Server Pages Servlets require you to write out entire page delivered with print statements Servlets require you to write.
Q: According to Intel, the Pentium conforms to the IEEE standards 754 and 854 for floating point arithmetic. If you fly in aircraft designed using a Pentium,
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 Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 37 - JavaServer Pages (JSP): Bonus for Java Developers Outline 37.1 Introduction 37.2 JavaServer.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
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,
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
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.
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.
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.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
JSP Most of the web developers deploying web applications using servlets mixes the presentation logic and business logic. Separation of business logic.
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,
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.
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.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
JSP Tag Libraries Lec Last Lecture Example We incorporated JavaBeans in “Course Outline” Example But still have to write java code inside java.jsp.
Jsp (Java Server Page) Is a server side program.
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)
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
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.
Chapter 11 Invoking Java Code with JSP Scripting Elements.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© 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.
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)
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
 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.
JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,
Chapter 14 Using JavaBeans Components in JSP Documents.
JSP Java Server Pages. Hello, !
JSP java server pages.
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
Scripted Page Web App Development (Java Server Pages)
Knowledge Byte In this section, you will learn about:
Java Server Pages B.Ramamurthy.
Object Oriented Programming in java
Introduction to JSP Dept. of B.Voc Software Development and System Administration St. Joseph’s College(Autonomous) Trichy-02 By Dr. J. Ronald Martin Introduction.
Presentation transcript:

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 first requested, a JSP is parsed into a java source file which is then compiled into a servlet class and run under the container JVM Initially, there is a performance hit However, there is a “build” mechanism to avoid unneeded parsing and compilation based on the date of the JSP page relative to the class file

2 Java Server Page Tags Directives Hidden Comments Declarations Expressions Scriptlets There are also a number of XML-type tags that begin with “<jsp:’ called “actions”

3 Directives Directives are compiler instructions that are processed when the page is compiled The format is Examples:

4 Directives At the top of each JSP is a page declaration page language=“java” language (see below) import=“...” list of packages to import errorPage=“...”substitute error page contentType=“...”usually “text/html” %> At present only Java can be used in a JSP

5 Directives This directive inserts the “static” contents of a file into the JSP at compile time The text becomes part of the JSP page It is useful for including code that is common to a number of pages, but for which you do not want to use a bean Example:

6 Hidden Comments These are used to document the page and are not sent to the client The format is Example: Any characters may be used in the body of a comment except the closing "--%>" marker which should be escaped as "--%\>".

7 Declarations These are used to declare variables or methods that have scope throughout the page The format is Examples: <%! String myString = "hello"; private String getData() { // Java code for the method goes here } %>

8 Declarations Every JSP contains implicit references to API objects that do not need to be declared: –request –response –pageContext –session –application –out –config –page –exception

9 Expressions The result of an expression is converted to a String and inserted into the output stream at the place where it occurs The format is Examples: Note that the expression is not terminated with a semicolon The parser simply wraps an out.print() or similar method around the expression as its argument

10 Scriptlets Scriptlets contain fragments of Java code The format is Scriptlet code can access implicit references and declared variables or methods Use a scriptlet to wrap a conditional or a loop around a block of HTML Examples: Please sign up! Welcome back!

11 Scriptlets The output HTML stream will vary depending on the value of the request parameter named “user” Note the use of the implicit request object which does not need to be declared with “ ” Example of scriptlets with an expression: The current number is:

12 Action This tag is used to include either static or dynamic content in the output stream If the file is dynamic, you can use to pass parameters to it Examples:

13 Action This tag takes the implicit request object (which contains the client request parameters and other CGI-type data) and forwards it to a target file - an HTML page, a servlet, or another JSP file Example: "> The tag is used to pass additional parameters to the target

14 Action: Java Beans JavaBeans are the component model for Java - the equivalent of all those fancy components you can obtain and use in the.NET world In a component model / market, developers go to the marketplace, pay for the component library they need, and wire it all together in a JSP using their IDE This has worked for other languages (e.g. Visual Basic), but has never developed for the Java market

15 Action: Java Beans A Java Bean is a class with the following –A default constructor (with no argument list) –A Set and Get method for each attribute (called a property in Java Bean terms) A JSP can use an action to instantiate and access an instance of the Java Bean class A JSP can use actions to access the other methods of an instance of the Java Bean A JavaBean can be monitored by listeners for changes to its parameters from the JSP

Java Bean public class MyJavaBean { private String propertyName; public MyJavaBean() { … } // Default Constructor public void setPropertyName(String theValue) { this.propertyName = theValue; } public String getPropertyName() { return this.propertyName; } } 16

17 Action: Java Beans and Example of how to set up a bean instance

18 Action: Java Beans This tag retrieves the value of a bean property and converts it to a String to display it in the page The format is: The name attribute points to the bean with the same id attribute used in the tag The property attribute is the name of the bean property you wish to display (there must be a corresponding Get method in the bean)

19 Java Beans in Scriptlets / Expressions Once a Java Bean has been instantiated, its instance name and its methods can be used in scriptlets: <% beanInstanceName.setPropertyName (“New_value”) %> or expressions:

20 Java Server Pages You can view the Java source code generated by the parser, but it's not a good idea to modify it The generated Java code is found in: Tomcat 6.0\work\Catalina\localhost\myapp\org\apache\jsp The class file for any Java Beans used must be in this directory for it to be found while compiling the generated JSP source code A copy of the class file for any Java Beans must also be located in the WEB-INF/classes directory for Tomcat to find it at run time (Proper classpath setting would probably fix this)

Model-View-Controller Multiple views of enterprise application and information is required – one for each type of user Leads to MVC Architecture – separation of functions Java Server Pages, Servlets, and Java Beans can be used to implement the MVC architecture for access to common application and/or information

Model-View-Controller The MVC Solution Enterprise Information System HTML View Classic Web Client Administrator Swing View XML Web Service Supplier B2B Agent

Model-View-Controller View (HTML/JSP) -Renders the Model -Requests updates from model(s) -Sends user gestures to controller -Allows controller to select view Controller (Servlets) -Defines application behavior -Maps user actions to model updates -Selects views for response -One for each functionality Model (Java Beans) -Encapsulates application state -Responds to state queries -Exposes application functionality -Notifies view(s) of changes Change Notification State Query State Change View Selection User gestures