1 Dickson K.W. Chiu PhD, SMIEEE Reference: Sun J2EE 1.4 Tutorial CSIT600b: XML Programming XML Programming Guide: Getting Started 2.

Slides:



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

JSP and Servelets.
CS4273: Distributed System Technologies and Programming I Lecture 11: JavaServer Pages (JSP)
Java Server Pages (JSP)
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
1 Dickson K.W. Chiu PhD, SMIEEE Thanks to Prof. SC Cheung (HKUST), Prof. Francis Lau (HKU) Reference: XML How To Program, Deitel, Prentice Hall 2001 CSIT600b:
Java Server Pages by Jon Pearce. JSP Documents JSP docs are XHTML Documents containing: –Fixed-Template Data: FTD HTML Components XML markup –JSP Components:
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
DT228/3 Web Development JSP: Directives and Scripting elements.
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,
Introduction to Servlet & JSP
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.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 37 - JavaServer Pages (JSP): Bonus for Java Developers Outline 37.1 Introduction 37.2 JavaServer.
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.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
1 Chapter 2 The Web Tier  Web Applications and Web ContainersWeb Applications and Web Containers  Dynamic Content CreationDynamic Content Creation 
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.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
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,
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
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 Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
3/6/00jsp00 1 Java Server Pages Nancy McCracken Northeast Parallel Architectures Center at Syracuse University.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
Java Servlets and Java Server Pages Norman White Stern School of Business.
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.
Web Technologies Java Beans & JSP By Praveen Kumar G.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
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.
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.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 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,
JSP JavaServer Pages. What is JSP? Java based technology that simplifies the development of dynamic web sites JSP pages are HTML pages with embedded code.
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.
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.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax.
Introduction to Servlets
Java Servlets By: Tejashri Udavant..
Java Server Pages By: Tejashri Udavant..
Scripted Page Web App Development (Java Server Pages)
Java Server Pages.
Java Server Pages B.Ramamurthy.
J2EE Lecture 1:Servlet and JSP
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

1 Dickson K.W. Chiu PhD, SMIEEE Reference: Sun J2EE 1.4 Tutorial CSIT600b: XML Programming XML Programming Guide: Getting Started 2

Dickson Chiu 2004CSIT600b 2p-2 Assignment Overview XSLT experiment - interactive try and error with IE6 Existing HTML sites Jtidy Parser XSLT1 Info Summary XSLT2XSLT3 WML HTML WAP access Browser access HTML J2EE environment

Dickson Chiu 2004CSIT600b 2p-3 Parsing a Web page with Jtidy Better parser than the standard Java library Clean up malformed and faulty HTML More functions Installation Download from Put Tidy.jar into H:\Sun\AppServer\lib Edit H:\Sun\AppServer\j2eetutorial14\examples\common\targets.xml Add red line for library

Dickson Chiu 2004CSIT600b 2p-4 Parsing source code // thanks to the TA, Mr Kawah Wong import javax.servlet.http.*; import javax.servlet.*; import java.io.*;import java.net.*; import org.w3c.tidy.*;import org.w3c.dom.*; public class Html2Dom extends HttpServlet { public Html2Dom() {} protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String urlStr = req.getParameter("url"); // get the parameter URL url = new URL(urlStr); // open the connection with that url URLConnection cn = url.openConnection(); // parse the html file into dom Tidy tidy = new Tidy(); tidy.setIndentContent(true); tidy.setXHTML(true); tidy.setWraplen(Integer.MAX_VALUE); Document doc = tidy.parseDOM(cn.getInputStream(), null); // print out the Dom tidy.pprint(doc, resp.getOutputStream()); }

Dickson Chiu 2004CSIT600b 2p-5 Front Page Interface CSIT600B HTML to DOM Demo HTML to DOM Demo URL:

Dickson Chiu 2004CSIT600b 2p-6 WAR Structure Duplicate directory of example hello2 for testing Include Tidy.jar Alias /result for the servlet Context root /html2dom You don’t need the frontpage, e.g.: ult?url= View the source and find it pretty- print with indentation

Dickson Chiu 2004CSIT600b 2p-7 Bonus – JSP Brief Overview J2EE tutorial Chap 12, 13 static data + JSP elements, which construct dynamic content Custom tag in tag library for reuse Use JavaBeans components for interfacing Properties - Read/write, read-only, or write-only Properties - Simple, which means it contains a single value, or indexed, which means it represents an array of values For each readable property, the bean must have a method of the form: PropertyClass getProperty() {... } 2 syntaxes - standard and XML Life Cycle Translation and Compilation Execution

Dickson Chiu 2004CSIT600b 2p-8 JSP Translation & Compilation Directives are used to control how the Web container translates and executes the JSP page. Scripting elements are inserted into the JSP page's servlet class. Expression language expressions are passed as parameters to calls to the JSP expression evaluator. jsp:[set|get]Property elements are converted into method calls to JavaBeans components. jsp:[include|forward] elements are converted into invocations of the Java Servlet API. The jsp:plugin element is converted into browser- specific markup for activating an applet. Custom tags are converted into calls to the tag handler that implements the custom tag.

Dickson Chiu 2004CSIT600b 2p-9 JSP Example – standard vs XML syntax taglib uri=" prefix="c" %> taglib uri=" prefix="fn" %> Hello My name is Duke. What is yours? <jsp:useBean id="userNameBean" class="hello.UserNameBean" scope="request"/> <jsp:setProperty name="userNameBean" property="name" value="${param.username}" /> 0}" > <html xmlns:c=" xmlns:fn=" > Hello My name is Duke. What is yours? <jsp:useBean id="userNameBean" class="hello.UserNameBean" scope="request"/> <jsp:setProperty name="userNameBean" property="name" value="${param.username}" />

Dickson Chiu 2004CSIT600b 2p-10 Bonus – JavaBean Brief Overview A constructor that takes no parameters Properties Read/write, read-only, or write-only Simple, which means it contains a single value, or indexed, which means it represents an array of values For each readable property, the bean must have a method of the form: PropertyClass getProperty() {... } For each writable property, the bean must have a method of the form setProperty(PropertyClass pc) {... }

Dickson Chiu 2004CSIT600b 2p-11 Advantages of using the XML syntax You can author a JSP document using one of the many XML-aware tools on the market, enabling you to ensure that your JSP document is well-formed XML. You can validate the JSP document against a document type definition (DTD). You can nest and scope namespaces within a JSP document. You can use a JSP document for data interchange between Web applications

Dickson Chiu 2004CSIT600b 2p-12 “Book.jspx” XML Example <books xmlns:jsp=" xmlns:c=" > ${book.surname} ${book.firstName} ${book.title} ${book.price} ${book.year} ${book.description} ${book.inventory}