Java Server Pages (JSP) Provide a cross-platform framework for creating dynamic web contents JSP Components: Static HTML/XML parts Special JSP Tags Snippets.

Slides:



Advertisements
Similar presentations
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Advertisements

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.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
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.
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.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
JavaServer Pages Fundamentals.
Using JavaBeans Components in JSP Documents. Contents 1. Why using beans? 2. What are beans? 3. Using Beans: Basic Tasks 4. Sharing Beans 5. Practice.
Java Servlets and Java Server Pages Carol Wolf Computer Science.
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.
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.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
 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,
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:
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaServer Page.
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.
Java Server Pages (JSP)
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
CSC 2720 Building Web Applications JavaServer Pages (JSP) JSP Directives and Action Elements.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 43 JavaServer Page.
©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.
1 Chapter 27 JavaServer Page. 2 Objectives F To know what is a JSP page is processed (§27.2). F To comprehend how a JSP page is processed (§27.3). F To.
JAVA SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra.
 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.
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.
JSP Based on
Java Server Pages By: Tejashri Udavant..
COMP9321 Web Application Engineering Semester 2, 2017
Scripted Page Web App Development (Java Server Pages)
Scope and State Handling in JSPs
Pre-assessment Questions
Introduction to Java Bean
Java Server Pages (JSP)
Java Server Pages JSP 11/11/2018.
Introduction to Java Server Pages
Introduction to Java Bean
Java Server Pages.
Java Server Pages (JSP)
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 (JSP) Provide a cross-platform framework for creating dynamic web contents JSP Components: Static HTML/XML parts Special JSP Tags Snippets of Java code called “scriptlets”

Client JSP file component JSP Container & Web Server request response

JSP Syntax HTML Comment: HTML Comment: Hidden Comment Hidden Comment <%-- documents a JSP file...comments are not sent to the client --%> --%>

JSP Syntax Declaration Declaration <%! int num;double salary[20]; String name; %> Expression Expression

JSP Syntax Scriptlet Scriptlet <% for (int k=0; k<20; k++) {salary[k] = k *10.0; if (k % 2) salary[k] *= 2; else salary[k] *= 3; }%>

Temperature Conversion Temperature Conversion Program Enter a temperature to convert: Select Conversion Type: <input type="radio" checked name="ttype" value="0">F-to-C C-to-F

Conversion Results <%!//variable declarations String TempStr, ConversionFlag;int InputVal, OutputVal; %> Conversion Result Degrees Farenheit Centigrade <% TempStr = request.getParameter("temp"); InputVal = Integer.parseInt(TempStr); ConversionFlag= request.getParameter("ttype"); if (ConversionFlag.equals("0")){ //F-to-C Conversion OutputVal = (int) (((((InputVal-32)*100.0)/9.0)*5)/100.0); %> <% } else { OutputVal = (int)((((InputVal *100.0)/5)* 9)/100.0) + 32; %> <% } %> Go back to home page

JSP Syntax Include Directive JSP TEST THE CURRENT DATE and TIME: OUTPUT: THE CURRENT DATE and TIME: February 2, :45:20

JSP Syntax Page Directive defines attributes that apply to an entire JSP page. page [language=“java”][extends=“package.class”] [import=“package.class”, …] [session=“true|false”][buffer=“none|8kb|sizekb”][autoFlush=“true|false”] [contentType=“mimeType [;text/html”]] %>

JSP Standard Actions <jsp:useBean> Associates a JavaBean with the JSP. <jsp:useBean id=“name” scope=“page|request|session|app” {class=“package.class” | type=“package.class” | beanName=“beanName” type=“typeName”}</jsp:useBean>

JSP Standard Actions <jsp:setProperty> Sets a property value or values in a bean. Used in conjunction with the action. < jsp:setProperty name=“beanName” {property=“*” | property=“propertyName” | property=“propertyName” param=“paramName” | property=“propertyName”value=“propertyValue”}/>

UseBean Sample Enter String: Reverse All Caps All Lower SpellCheck The word is The word has been processed into: <%int selOption=Integer.parseInt(request.getParameter(“proctype”); String processStr=“”; switch (selOption){ case 1: processStr = procword.reverse( ); break; case 2: processStr = procword.upper( ); break; case 3: processStr = procword.lower( ); break; case 4: if ( procword.spellchk( )) { %>RIGHT WRONG<%} ; break; } %>

/** * Title: ProcWord bean * Description: A java bean used to process a character string 1.0 */ package myClass; public class ProcWord { private String word; public void setWord(String wordparam){ word = wordparam; } public String reverse(){ return((new StringBuffer(word).reverse()).toString()); } public String upper() { return word.toUpperCase(); } public String lower() { return word.toLowerCase(); } public boolean spellchk(){ if (word.equals("HELLO")) return true; else return false; }

JSP Standard Actions <jsp:getProperty> Use to access the properties of a bean. < jsp:getProperty name=“beanName” property=“propertyName” /> The word is The word has been processed into: <%int selOption=Integer.parseInt(request.getParameter(“proctype”); String processStr=“”; switch (selOption){ case 1: processStr = procword.reverse( ); break; case 2: processStr = procword.upper( ); break; case 3: processStr = procword.lower( ); break; case 4: if ( procword.spellchk( )) { %>RIGHT WRONG<%} ; break; } %>

JSP Standard Actions <jsp:forward> Forwards a client request to an HTML file, JSP file, or servlet for processing. The lines after in the JSP file are not processed. OR </jsp:forward>

JSP Standard Actions <jsp:include> Includes a static file or sends a request to a dynamic file. OR </jsp:include> EXAMPLES:

Notes on Using JavaBeans Make sure that you save your class file in the folder that you named in your package line. For example, if the package line is package myClass; The file must be saved in C:\Tomcat\webapps\TESTFILES\Web-inf\Classes\myClasswhere: TESTFILES is the folder where the index.html and the JSP files are stored.