Knowledge Byte In this section, you will learn about:

Slides:



Advertisements
Similar presentations
9 Copyright © 2005, Oracle. All rights reserved. Modularizing JavaServer Pages Development with Tags.
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
 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.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
DT211/3 Internet Application Development
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
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.
Web programming for project students Dr Jim Briggs.
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.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
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.
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.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
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.
JSP Standard Tag Library
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.
® IBM Software Group © 2007 IBM Corporation JSP Custom Tags
Introduction to Java Server Pages (JSPs) Robert Thornton.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
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.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Chapter 7 Using Custom Tag Libraries and the JSP Standard Tag Library.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Chapter 5 Generating Dynamic Content. Creating a JSP Page A Sample JSP Page: easy.jsp JSP is Easy JSP is as easy as =
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 An introduction to JSP. Containers and Components Several clients – one system.
JSTL The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
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.
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.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
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.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
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.
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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Apache Struts Technology A MVC Framework for Java Web Applications.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
JSP: Actions elements and JSTL
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.
Java Servlets.
Pre-assessment Questions
Java Server Pages B.Ramamurthy.
Objectives In this lesson you will learn about: Need for servlets
JSP Directives 1-Jan-19.
JSP implicit objects & directive elements
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Knowledge Byte In this section, you will learn about: JSP Container Model Character encoding in JSP JSP and XML integration JavaServer Pages Standard Tag Library (JSTL) Collaborate

JSP Container Model JSP container is a Web container that stores and manages various JSP components. The javax.servlet.jsp package contains various classes and interfaces that define the rules and strategies for communication between the JSP container and a JSP page. Collaborate

JSP Container Model (Contd.) The contracts between a JSP Container and a JSP page includes: JSP Page Implementation Class JSP Page Model Buffering Precompilation of a JSP Page Debugging Requirement of a JSP Page Collaborate

JSP Container Model (Contd.) JSP Page Implementation Class: Is a servlet class, which is created by a JSP container by translating a JSP page. Is instantiated at the request time. Handles requests by generating a corresponding response for the request. Defines: API contracts Request and Response parameters Collaborate

JSP Container Model (Contd.) JSP Page Model: Describes how to create a response object from a request object of a given protocol. Defines: Protocols to find JSP page instance Methods to define contract between JSP page author and JSP container The HttpJspPage Interface Collaborate

JSP Container Model (Contd.) JSP Page Model (Contd.) The following figure shows the interaction between the JSP container and a JSP page: Collaborate

JSP Container Model (Contd.) Buffering Is a technique used by the JSP container to buffer the response sent by the server. Works only if the JSP buffer attribute is set to true. Requires you to use the javax.servlet.jsp.JspWriter class in your JSP page. Collaborate

JSP Container Model (Contd.) Precompilation of a JSP Page The JSP container supports simple precompilation protocol and some reserved parameter names to serve request from Web clients. All the request parameter names that start with the prefix, jsp are reserved by the JSP specification. A request made to the JSP page that has a request parameter with name jsp_precompile is a precompile request. The JSP container precompiles the JSP page into the JSP page implementation class when the container finds the jsp_precompile request parameter value set to true. Collaborate

JSP Container Model (Contd.) Debugging Requirement of a JSP Page The JSP container generates source map debugging information for JSP pages and tag files. The JSP compiler generates .class files with a SourceDebugExtension attribute. The generated class maps each line of JSP code with the equivalent generated Java code. Collaborate

Character Encoding in JSP Character encoding maps a character set to rules that defines how different characters needs to be represented. Java-platform supported character-encoding schemes are: US-ASCII ISO-8859-1 UTF-8 UTF-16 Various encoding types in JSP are: Page encoding Response encoding Request encoding Collaborate

Character Encoding in JSP (Contd.) Page encoding: Encodes the JSP page or the tag file itself. Is determined from the following sources: JSP configuration element, page-encoding value whose URL pattern matches the page. The pageEncoding attribute of the JSP page directive. The charset value for the contentType attribute of the JSP page directive. Collaborate

Character Encoding in JSP (Contd.) Response character encoding: Encodes the response generated in text format from a JSP page. Is determined from the following sources: The CHARSET value of the contentType attribute of the page directive. The encoding specified by the pageEncoding attribute. The pageEncoding value of a JSP property group. Collaborate

Character Encoding in JSP (Contd.) Request character encoding (Contd.): Encodes the parameters of incoming requests. Uses the JavaServer Pages Standard Tag Library (JSTL) <fmt:requestEncoding> tag to control the encoding from the JSP page. Collaborate

JSP and XML Integration JSP pages can be written using XML syntax. JSP pages with XML syntax are called JSP documents. JSP documents have .jspx extension. Advantages of using JSP XML syntax are: JSP code can be developed in an XML compatible syntax. XML content can be added into a JSP document using the new XML syntax. A container that follows the JSP 1.2 specification will automatically validate the XML syntax of the JSP document. Collaborate

JSP and XML Integration (Contd.) The following table lists the differences between JSP tags and XML tags: Type JSP Tag JSP XML Tag page directive <% page ... %>   <jsp:directive.page ... /> include directive <%@ include ... %> <jsp:directive.include ... /> taglib directive <%@ taglib ... %> <jsp:root xmlns:prefix="taglibURI"> ... </jsp:root> declaration <%! declaration %> <jsp:declaration> declaration </jsp:declaration expression <%= expression %>  <jsp:expression> expression </jsp:expression scriptlets <% scriptlet_code %> <jsp:scriptlet> scriptlet_code </jsp:scriptlet> Collaborate

JSP and XML Integration (Contd.) JSP XML Root Element The <jsp:root> element specifies the root element of a JSP document. The attributes of <jsp:root> element can be used to specify the JSP specification version and to include a tag library in a JSP document. Following is the syntax of using the <jsp:root> element in a JSP document: <jsp:root xmlns:jsp=”path” xmlns:version=”JSP version”prefix1=” “ > </jsp:root> Collaborate

JavaServer Pages Standard Tag Library (JSTL) Is a collection of methods and standard tags that you use in JSP pages to perform repetitive tasks, instead of using Java scriptlet code. The four groups in which the JSTL is divided are: Core tag library Formatting/Internationalization tag library Database tag library XML tag library Collaborate

JavaServer Pages Standard Tag Library (JSTL) (Contd.) Core Tag Library It is a collection of tags that are used to perform common repetitive tasks in JSP pages. It also consists of tags related to JSP expressions, flow control, looping, input, and output. In addition, it provides tags for URL-based resources whose content can be included or processed within a JSP page. You need to prefix the alphabet, c, when you use core tag library. Collaborate

JavaServer Pages Standard Tag Library (JSTL) (Contd.) Core Tag Library (Contd.) It is divided into four groups depending on the function that the tag performs: Variable support tags Flow control tags URL management tags Miscellaneous tags Collaborate

JavaServer Pages Standard Tag Library (JSTL) (Contd.) Formatting or Internationalization Tag Library It consists of tags that support internationalization of JSP pages. You need to prefix, fmt while using internationalization tag. It is divided into three groups depending on the function that the tag performs: Setting locale tags Messaging tags Number and date formatting tags Collaborate

JavaServer Pages Standard Tag Library (JSTL) (Contd.) SQL Tag Library It consists of tags that provides a mechanism to interact with databases. You prefix, sql before an SQL tag. Various tags within the SQL tag library are: setDataSource tag query tag update tag transaction tag Collaborate

JavaServer Pages Standard Tag Library (JSTL) (Contd.) XML Tag Library It consists of tags that can access XML elements to process or parse an XML document. You prefix the symbol, x with the XML tags. It is divided into three groups depending on the function, the tag performs: Core tags Flow Control tags Transformation tags Collaborate

From the Expert’s Desk This section, will introduce the following: Best Practices on Developing JSP Application FAQs on JSP Collaborate

Best Practices Developing JSP Applications Various issues, such as application performance, scalability, security, and speed, needs to be considered while developing JSP applications. Some best practices that you can implement to enhance JSP applications are: Proper usage of JSP objects scope Minimize Java code in JSP pages Proper use of include mechanism Use standard libraries for custom tags Collaborate

Best Practices (Contd.) Developing JSP Applications (Contd.) Proper usage of JSP objects scope Use page scope for objects, which need to be available to only a specific page. You do not need to explicitly remove the objects declared with page scope when it is not required. Use request scope for objects, which need to be shared between JSP pages while processing a request. Object with request scope are automatically discarded once the processing of the request ends. Use session scope for objects, which need to be shared between the JSP pages involved in maintaining client session. You need to explicitly remove the object with session scope when it is not required. Collaborate

Best Practices (Contd.) Developing JSP Applications (Contd.) Minimize Java code in JSP pages JSP page that embeds a considerable amount of Java code is difficult to design and manage. Any compilation error present in the Java code of the JSP page cannot be determined before it is deployed and executed. You can use custom tag and JavaBean to minimize the Java code in the JSP page. Collaborate

Best Practices (Contd.) Developing JSP Applications (Contd.) Proper use of include mechanism Use include directive to include the content of a static resource during translation phase. Use include action dynamically to include the response of a resource during the execution phase. Use include directive to include static contents, such as copyright information and contact addresses. Use include action to include dynamic contents that might change during runtime or if the calling page dynamically decides what content to include. Collaborate

Best Practices (Contd.) Developing JSP Applications (Contd.) Use standard libraries for custom tags Use the standard tag libraries to perform repetitive task in a JSP page. JSTL provides a set of standard tags to perform common tasks, such as database access and formatting an XML document Collaborate

FAQs How can you edit the web.xml deployment descriptor file of a JSP application to specify a new custom tag mapping for your JSP application? When you deploy a JSP application in the J2EE application server a directory with the name of your application is created. This directory contains a WAR directory that contains your application file in the J2EE Web application directory structure. The web.xml deployment descriptor file resides in the WEB-INF directory. If your application name is MyApp and your J2EE application server is located in the C drive, you can locate the web.xml file in: C:\Sun\AppServer\domains\domain1\applications\j2ee-apps\MyApp\war-ic_war\WEB-INF Open the web.xml file in a text editor and modify the taglib element to map to the TLD file of the new tag library. Collaborate

FAQs (Contd.) Can you use Filters in JSP application? Yes, you can use filters to intercept request and responses transmitting between the client and your JSP application. You can use filters, to perform tasks, such as providing information of the client to the JSP application and compressing the responses sent by your JSP application. Collaborate

Challenge How can you specify to the container that it needs to queue multiple requests to the JSP page and to send only one request at a time? How can you specify the buffer size of the out object? The exception JSP implicit object is an instance of the ___________class. Specify the implicit object and the corresponding method used to log error messages in a JSP page. The _______________ constant can be used in a tag handler to specify that the container needs to skip evaluating the remaining content of the JSP page. Collaborate

Solution 1. Set the value of isThreadSafe attribute to false. 2. Set the value of the page directive attribute, buffer, to a specified buffer size. 3. java.lang.Throwable. 4. application implicit object (ServletContext) and method is log(java.lang.String) and log(java.lang.Throwable, java.lang.String). 5. SKIP_PAGE. Collaborate