1 Java Server Pages Allows the embedding of Java commands in a page of HTML. Popular for UI heavy solutions. These commands are then interpreted by a JSP.

Slides:



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

JSP and Servelets.
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Server Pages (JSP)
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.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
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.
Apache Tomcat Server Typical html Request/Response cycle
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,
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
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.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems JavaServer Pages (JSP)
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
1 Guide to JSP common functions 1.Including the libraries as per a Java class, e.g. not having to refer to java.util.Date 2.Accessing & using external.
UNIT-V The MVC architecture and Struts Framework.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 Servlet How can a HTML page, displayed using a browser, cause a program on a server to be executed?
Java Beans.
JSP Java Server Pages Softsmith Infotech.
Introduction to Java Server Pages (JSPs) Robert Thornton.
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)
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
J2EE Structure & Definitions Catie Welsh CSE 432
Mark Dixon 1 12 – Java Beans. Mark Dixon 2 Session Aims & Objectives Aims –To cover the use of Java Beans Objectives, by end of this week’s sessions,
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,
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
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.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Jsp (Java Server Page) Is a server side program.
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
CSI 3125, Preliminaries, page 1 Compiling the Program.
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.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
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 ( )
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.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
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.
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.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
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.
Scripted Page Web App Development (Java Server Pages)
MSIS 655 Advanced Business Applications Programming
JavaScript an introduction.
Java Server Pages (JSP)
JavaServer Faces: The Fundamentals
Tutorial 10: Programming with javascript
Scripted Page Web Application Development (Java Server Pages)
Presentation transcript:

1 Java Server Pages Allows the embedding of Java commands in a page of HTML. Popular for UI heavy solutions. These commands are then interpreted by a JSP engine in the webserver (like ASP/PHP). Therefore any webserver must have a JSP engine installed and attached in order to process JSP pages (IIS does not have a default engine installed but one such as TomCat can be attached).

2 JSP JSP is a Server Side Include (SSI) mechanism. A JSP can contain standalone Java code, i.e. no other elements are needed to interpret that page. A JSP can contain Java code which contacts other elements, e.g. the Java code in your JSP page could create objects, contact a database, etc.

3 JSP vs Servlet A servlet is a Java class which is instantiated and executed when its URL is called. A JSP is a web page which has Java commands embedded in it. Servlets are used for situations where a great deal of functionality is required. Servlets can also perform some operations and access resources JSPs can’t. JSPs are used in situations where relatively simple code is needed and a servlet would be viewed as overkill.

4 Procedure 1. Name your page with the extension JSP. 2. Put in Java expressions which will be evaluated into the tag format: e.g.. The result of the evaluated expression will replace this tag in the final page. (The result of the expression can also be discarded). HTML comments can be used to comment the JSP code.

5 Objects in a JSP Can create, and use, an object of any available Java class type in a JSP Example, assume the class ‘classname’ has been compiled and the bytecode is visible to the page containing the following tag A session is a continuous communication session between a client (e.g. Browser) and the server (e.g. Tomcat/Glassfish)

6 Using an Object in a JSP To call a method in the object which will return no result use the tag: Note that the statement ends with a semi-colon. If the method returns a value which you would like inserted into the web page then use the tag: Note there is no semi-colon in this statement.

7 Example Name:

8 Example public class classUsedByJSP { String name; public String getName() { return name; } // End returnName public void setName(String nameSupplied) { name = nameSupplied; } // End setName } // End classUsedByJSP

9 Using JavaBeans in JSP A Java Bean is a Java class that’s written in a particular way. One aspect of a Bean is that methods which obtain the value of a variable and alter the value of a variable are written using the words ‘get’ and ‘set’ which is always followed by the name of the variable which has the first letter capitalised.

10 Example of a basic JavaBean class beanEg { private int amount; // Note the capital letter in the get and set methods public void setAmount(int value) {} public int getAmount() {} } // End class beanEg

11 JSP Forms and Beans Can write a class using some of the characteristics of a Bean. This will allow form component values to be automatically placed in an object of this class by the VM. Conversion to different data types is also done automatically.

12 Procedure Write the HTML form and name the form elements. Write the class definition and use same names in the class for variables as was used in the form. Methods which alter and access the elements should be named get and set. Write the JSP file and tell VM to setup an object of the class type

13 Procedure Insert an instruction in the JSP file to tell the VM to call the methods in the object which match the names of the form components supplied. The VM automatically inserts values using methods according to names and you are now free to use the relevant object in your JSP page.

14 Example – Basic JSP

15 Example – Class definition public class dataClass { private String string; private int value; public void setString(String stringSupplied) { string = stringSupplied;} // End setString public String getString() { return string; } // End getString public void setValue(int valueSupplied) { value = valueSupplied; } // End setValue public int getValue() { return value; } // End getValue } // End dataClass

16

17 Cookies Can set and get cookie via JSP pages (and servlets) Cookies not popular due to prejudice on consumers part.

18 Cookies-setting <% Cookie authorised = new Cookie("makeCookie", "true"); authorised.setMaxAge(60*60*24*365); response.addCookie(authorised); %>

19 Cookies-getting <% Cookie[] cookieList = request.getCookies(); for(int count=0;count<cookieList.length;count++) out.println(cookieList[count].getName()+" "); %>

20 Tag Libraries Custom JSP tags available if JSP is run on specific web server Tag libraries generally offer useful features which allow rapid development of JSP pages, like simplified database access.

21 JSP Execution JSP pages are actually executed as servlets. When a JSP engine receives a JSP page it creates a standard servlet from a template and inserts the embedded code into this servlet. It then executes the servlet and replaces the JSP code with the results.