Java Server Pages By: Tejashri Udavant..

Slides:



Advertisements
Similar presentations
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Advertisements

JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
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,
Integrating Servlets and JavaServer Pages Vijayan Sugumaran School of Business Administration Oakland University Parts of this presentation provided by.
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 server pages is a technology for developing portable java web applications that runs on a java web server. Main motivation behind developing JSP was.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Java Servlets & Java Server Pages Brad Rippe Fullerton College.
Java Server Pages CS-422. What are JSPs A logical evolution of java servlets –most servlets dynamically create HTML and integrate it with some computational.
1 APPENDIX D OVERVIEW OF JSP, JSTL, and EL TAGS. 2 OVERVIEW OF JSP, JSTL, and EL TAGS This appendix describes how to create and modify JSP pages in JD.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
JavaServer Pages Fundamentals.
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 JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
1 Servlet & JSP Serkan Erdur & Levent Özgür. 2 What is Servlet? Java application that runs on the server side Answers html requests and produces dynamic.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
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.
JSP Most of the web developers deploying web applications using servlets mixes the presentation logic and business logic. Separation of business logic.
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.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
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.
Java Server Pages (JSP) Provide a cross-platform framework for creating dynamic web contents JSP Components: Static HTML/XML parts Special JSP Tags Snippets.
1 JSP – Java Server Page DBI – Representation and Management of Data on the Internet.
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.
3/6/00jsp00 1 Java Server Pages Nancy McCracken Northeast Parallel Architectures Center at Syracuse University.
Java Server Pages Introduction. Servlet Drawbacks Web page designer will need to know servlets to design the page. Servlet will have to be compiled for.
CSC 2720 Building Web Applications JavaServer Pages (JSP) JSP Directives and Action Elements.
JSP. Types of JSP Scripting Elements Expressions of the form, which are evaluated and inserted into the servlet's output. Scriptlets of the form, which.
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.
Web Technologies Java Beans & JSP By Praveen Kumar G.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
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 ( )
JSP – Java Server Page DBI – Representation and Management of Data on the Internet.
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.
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.
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.
JSP Java Server Pages. Hello, !
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax.
JSP Action Elements Lec - 37.
JSP java server pages.
Java Server Pages (JSP)
COMP9321 Web Application Engineering Semester 2, 2017
Scripted Page Web App Development (Java Server Pages)
Scope and State Handling in JSPs
Including Files and Applets in JSP Pages
Pre-assessment Questions
Introduction to JSP Java Server Pages
JSP(Java Server Pages)
Java Server Pages (JSP)
Java Server Pages JSP 11/11/2018.
Introduction to Java Server Pages
Java Server Pages.
Java Servlets & Java Server Pages
Java Server Pages B.Ramamurthy.
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.
Scripted Page Web Application Development (Java Server Pages)
Web Technologies Java Beans & JSP
Presentation transcript:

Java Server Pages By: Tejashri Udavant.

Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java) from its presentation (html) JSP specification builds on the functionality provided by the servlet specification.

How do JSP’s Work checks converts Forwards to compiles index.jsp Servlet/JSP Server checks Browser converts Forwards to index.java Generated Servlet compiles

Basic JSP Syntax Contains html code like static html pages with the JSP tags and scripting included in the page. Three basic types of jsp tags Scripting Elements Directive Elements Action Elements

Scripting Elements Allow java code – variable or method declarations, scriptlet, and expressions. Declaration tag <%! … %> Scriptlet tag <% … %> Expression tag <%= … %>

Declaration Tag <%! … %> Allows you to declare page wide variables and methods. <%! int counter = 0; %> <%! Vector beanList = new Vector(); %> Methods and variables have class scope Note, code must end with ; like any java code

Scriptlet Tag <% … %> Used to include small pieces of Java code <% for(Enumeration e = beanList.elements(); e.hasMoreElements(); ) { UserBean uBean = (UserBean) e.nextElement(); out.println( uBean.getUserName() ); } %>

Expression Tag <%= … %> Accepts any Java expression, evaluates the expression, converts to a String, and displays. <%= counter %> <%= uBean.getUserName() %> Short hand for: <% out.println( uBean.getUserName() ); %>

JSP Directives Directives provide global information to the JSP engine For example, a directive can be used to import java classes. Directive elements have a syntax of the form <%@ directive … %>

Page Directives The page directive defines a number of page dependent attributes <%@ page language=“Java” [ extends=“className” ] [ import=“importList” ] [ session= “true|false” ] [ buffer=“none|sizekb” ] [ autoFlush=“true|false” ] [ isThreadSafe=“true|false” ] … %>

Page Directive If language attribute is set, must be = “Java” Default import list is java.lang.*, javax.servlet.*, javax.servlet.jsp.* and javax.servlet.http.*. If session = “true” then default session variable of type javax.servlet.http.HttpSession references the current/new session for the page.

Include Directive <%@ page include file=“relativeURL” %> The include directive is used to inline text and/or code at JSP page translation-time. <%@ page include file=“relativeURL” %> <%@ page include=“/navbar.html”%>

JSP Actions The syntax for action elements is based on XML(i.e. they have a start tag, a body, and an end tag). The JSP specification includes some action types that are standard. New action types are added using the taglib directive.

Standard Actions Web container implements these actions <jsp:useBean> <jsp:setProperty> <jsp:getProperty> <jsp:include> <jsp:forward> <jsp:plugin> <jsp:param>

Standard Actions <jsp:useBean> Associates an instance of a bean to a variable to use with in the jsp page <jsp:useBean id=“name” scope=“page|request|session|application” class=“className” type=“typeName”> … </jsp:useBean>

Standard Actions - useBean id – variable name to reference instance of class scope page – javax.servlet.jsp.PageContext Objects only accessible from within the page request ServletRequest Objects accessible in pages processing request where bean is created session – HttpSession Objects accessible from user session application – ServletContext Objects accessible in pages belonging to same application

Standard Actions - useBean Type (optional) Allows scripting variable to be cast to another type from implementation class, java casting rules apply. Class Fully qualified class name that defines the implementation of the object

Standard Actions - setProperty <jsp:setProperty> Sets the value of properties in a bean <jsp:setProperty name=“beanName” property=“propertyName”|(param=“parametername”|value=“propertyValue”)/> Use property=“*” to set all properties from the request

Standard Actions - setProperty Name Variable name as defined in useBean Property Name of the bean property Request Name of the request parameter (if omitted same name as bean property name) Value Value assign property (Performs necessary conversions)

Standard Actions - getProperty Gets the value of properties in a bean <jsp:getProperty name=“beanName” property=“propertyName”/> Name Variable name as defined in useBean Property Name of the bean property to retrieve

Standard Actions – jsp:include Allows you to include resources in the same context as the current page <jsp:include page=“url” flush=“true”/> page: Relative url flush: If true, buffer is flushed

Standard Actions – jsp:forward Allows you to dispatch the request to a different page <jsp:forward page=“url”/> page: Relative url

Standard Actions - <jsp:plugin> Creates HTML that contains OBJECT or EMBED constructs that result in Java Plugin download and execution of Applet <jsp:plugin type=“applet” code=“applet.class” codebase=“/html”> <jsp:fallback> <p>Can’t display applet</p> </jsp:fallback> </jsp:plugin> Fallback is used if the plugin cannot be started

Standard Actions - jsp:param Used to provide key/value information for <jsp:include>, <jsp:forward>, and <jsp:plugin> <jsp:param name=“name” value=“value”/> Name and value are mandatory

Access Models Two approaches to building application with JSPs Model 1: JSP page processes all input Model 2: Servlet acts as a controller and directs http traffic to appropriate responses

Model 1 JSP is responsible for processing incoming requests and replying to clients All data access is through beans browser JSP Database BEAN

Model 2 Combine use of servlets and JSP Servlet acts as controller, JSP as presentation layer Database servlet browser Beans JSP