Chapter 11 Invoking Java Code with JSP Scripting Elements.

Slides:



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

CS4273: Distributed System Technologies and Programming I Lecture 11: JavaServer Pages (JSP)
Java Server Pages (JSP)
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
JSP – Java Server Pages Part 1 Representation and Management of Data on the Internet.
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.
JSP Java Server Pages Reference:
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,
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.
Java web development Servlet & Java server pages.
CSCI 6962: Server-side Design and Programming History and Background.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
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.
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.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
1 JSP – Java Server Pages Representation and Management of Data on the Internet.
Introduction to JSP Based on: Marty Hall, Larry Brown, Core Servlets and JavaServer Pages.
What Are Beans? beans are simply Java classes that are written in a standard format. A bean class must have a zero-argument (default) constructor. A bean.
JSP Java Server Pages Softsmith Infotech.
Jordan Anastasiade. All rights reserved.
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.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
16-Oct-15 JSP Implicit Objects. 2 JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
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.
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.
1 JSP – Java Server Page DBI – Representation and Management of Data on the Internet.
Jsp (Java Server Page) Is a server side program.
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.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
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.
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.
SKT-SSU IT Training Center Servlet and JSP. Chapter Eleven: Invoking Java Code with JSP Scripting Elements.
INVOKING JAVA CODE WITH JSP SCRIPTING ELEMENTS. Creating Template Text A large percentage of your JSP document consists of static text (usually HTML),
 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 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.
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, !
Developing JavaServer Pages
JSP Java Server Pages Reference:
COMP9321 Web Application Engineering Semester 2, 2017
Pre-assessment Questions
Invoking Java Code from JSP
JSP Syntax.
Introduction.
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.
Web Technologies Java Beans & JSP
Presentation transcript:

Chapter 11 Invoking Java Code with JSP Scripting Elements

Contents 1.Creating Template Text 2.Invoking Java Code from JSP 3.Using JSP Expressions 4.Example: JSP Expressions 5.Writing Scriptlets 6.Scriptlet Example 7.Using Scriptlets to Make Parts of the JSP Page Conditional 8.Using Declarations 9.Declaration Example 10.Using Predefined Variables

1. Creating Template Text A large percentage of your JSP document consists of static text HTML looks just like normal HTML Using tools to build the Web pages “template text is passed straight through” You need to put in the template text

2. Invoking Java Code from JSP

2. Invoking Java Code from JSP (Cont.) Expressions of the form Scriptlets of the form Declarations of the form

3. Using JSP Expressions Current time: Predefined Variables request, the HttpServletRequest response, the HttpServletResponse session, the HttpSession associated with the request out, the Writer (a buffered version of type JspWriter) application, the ServletContext Tomcat Autogenerated Servlet Source Code: install_dir/work/Standalone/localhost/_

4. Example: JSP Expressions

5. Writing Scriptlets complex than output the value of a simple expression  explicitly send output to the resultant page <% String queryData = request.getQueryString(); out.println("Attached GET data: " + queryData); %> Attached GET data:

5. Writing Scriptlets (Cont.)

6. Scriptlet Example JSP page that uses the bgColor request parameter to set the background color of the page

7. Using Scriptlets to Make Parts of the JSP Page Conditional

7. Using Scriptlets to Make Parts of the JSP Page Conditional (Cont.)

8. Using Declarations Define methods or fields Define most methods with separate Java classes, not JSP declarations.

8. Using Declarations (Cont.)

9. Declaration Example prints the number of times the current page has been requested since the server was booted Accesses to page since server reboot:

10. Using Predefined Variables Variable names the autogenerated servlet uses 1. request is the HttpServletRequest associated with the request 2. response is the HttpServletResponse associated with the response to the client 3. out is the writer used to send output to the client 4. Session is the HttpSession object associated with the request 5. application is the ServletContext as obtained by getServletContext 6. config is the ServletConfig object for this page

10. Using Predefined Variables (Cont.) 7. pageContext give a single point of access to many of the page attributes. 8. page is simply a synonym for this and is not very useful

Q & A? Thank you!