Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.

Slides:



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

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.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
DT211/3 Internet Application Development
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
CS320 Web and Internet Programming JSP Scripting Elements and Page Directives Chengyu Sun California State University, Los Angeles.
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,
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.
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.
 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.
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.
JSP Java Server Pages Softsmith Infotech.
Introduction to Java Server Pages (JSPs) Robert Thornton.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Jordan Anastasiade. All rights reserved.
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.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaServer Page.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Web App GUI: JSP Basics & Forms 3680 Enterprise Programming.
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.
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.
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.
Chapter 3 JSP Overview. The Problem with Servlets processing the request and generating the response are both handled by a single servlet class Java programming.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 43 JavaServer Page.
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.
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 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,
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 Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JSP Java Server Pages. Hello, !
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.
JSP java server pages.
Developing JavaServer Pages
Java Server Pages.
Pre-assessment Questions
Knowledge Byte In this section, you will learn about:
Invoking Java Code from JSP
Java Server Pages.
JSP Directives 1-Jan-19.
JSP implicit objects & directive elements
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:

Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai

Chapter 52 Objectives In this chapter, you will: Use the JSP page directives to determine some characteristics of JSP pages Use JSP include directive and include action to include content from another file Use simple JSP scripting elements Understand variable duration Use JSP comments to make your code more readable

Chapter 53 Page Directives Page directive attributes apply to the entire JSP page:

Chapter 54 Import Attribute Make Java classes available to the scripting environment Use Java API to add power to your JSP script When a Java class is imported to a JSP page, you can reference this class without explicitly specify the class package names

Chapter 55 Using java.util.Date class Without import: If the class imported, then:

Chapter 56 Session Attribute A session attribute can hold information across multiple requests A session begins when a user requests a JSP page at the first time The session attribute specifies how the page uses the predefined session object in JSP Default value is true If the value is set to false, then no session is created

Chapter 57 Session Object The method isNew() tests whether the session is newly created The method getCreationTime() returns when the session is created

Chapter 58 Buffer Attribute Specifies the size of the buffer used by the implicit out variable If a buffer is specified then output is buffered with a buffer size not less than the specified size

Chapter 59 Clear Buffer out.clear() clears whatever is buffered in the output stream Let's send some text to the HTML output stream The content is buffered The buffered content is not cleared

Chapter 510 isThreadSafe Attribute Specify whether to allow more than one thread to execute the JSP code

Chapter 511 Thread A thread is a process that handles client requests by executing the code sequentially Each client request for this page generates a thread that requests access to this code segment

Chapter 512 AutoFlush Specify whether the buffered output should be sent automatically when the buffer is filled:

Chapter 513 ErrorPage Specify a JSP page that can handle any exceptions that are not handled in the current page

Chapter 514 IsErrorPage Specify whether or not the current page can act as the error page for other JSP pages (default is false)

Chapter 515 Include Files Usage: –Provide the same navigation links and footer on each of the pages –Reuse JSP code

Chapter 516 Include Directive The content of the specified page is read at translation time (when it is converted into its corresponding servlet) and is merged with the original page when the page is requested for the first time After the original JSP page has been request, updating included file has no impact on the original file

Chapter 517 Include Action The action does not merge the actual contents of the specified page at translation time The page is included each time the JSP page is requested That means whenever you modify the included file, the changes are reflected the next time the page is requested

Chapter 518 Declaration A declaration is used to declare variables and methods in the scripting language used in a JSP page The variables and methods declared are inserted into the servlet class generated when the JSP container translates the JSP page A declaration has the following syntax:

Chapter 519 Declaration Example <%! int count = 0; public int getCount(){ return ++count; } %> Variables are shared among all clients

Chapter 520 JSP Expressions Insert a value directly into the output stream:

Chapter 521 JSP Scriptlets A scriptlet is a code fragment that is executed at request-processing time You can embed any valid Java language code inline between the tags The basic syntax is:

Chapter 522 Variable Duration The duration of variable (also called its lifetime) is the period during which the variable exists in memory Variables of instance duration exist from the point at which the corresponding servlet that defines them is loaded into memory Local variables are created when program control reaches their declaration

Chapter 523 Variable Duration They exist while the block in which they are declared is active, and they are destroyed when the block in which they are declared is exited Variables defined in declaration have instance duration Variables defined in scriptlet have local duration

Chapter 524 Comments Improve your program’s readability Ignored when the program is translated There are two types of comments: –Content comments –And server-side comments

Chapter 525 Content Comments Sent back the client via response output stream They are not displayed on the browser The same syntax as comments in HTML: It can include dynamic data: <!-- JSP Page = -->

Chapter 526 Server-side Comments They are ignored at translation time They are not sent to clients <%-- multiple line comments -- %> <% /* Multiple line comments */ %>