Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax.

Slides:



Advertisements
Similar presentations
Chapter 81 JavaBeans JavaServer Pages By Xue Bai.
Advertisements

 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Chapter 91 Scopes of Variables and JavaBeans JavaServer Pages By Xue Bai.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
COMP201 Java Programming Part III: Advanced Features Topic 16: JavaServer Pages (JSP) Servlets and JavaServer Pages (JSP) 1.0: A Tutorial
JavaServer Pages TM Introduce by
Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
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.
Component-Based Software Engineering Internet Applications Paul Krause.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
Using JavaBeans Components in JSP Documents. Contents 1. Why using beans? 2. What are beans? 3. Using Beans: Basic Tasks 4. Sharing Beans 5. Practice.
1 Chapter 2 The Web Tier  Web Applications and Web ContainersWeb Applications and Web Containers  Dynamic Content CreationDynamic Content Creation 
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.
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)
Jordan Anastasiade. All rights reserved.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
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,
Chapter 8 Cookies And Security JavaScript, Third Edition.
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.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
Java Server Pages (JSP) Provide a cross-platform framework for creating dynamic web contents JSP Components: Static HTML/XML parts Special JSP Tags Snippets.
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.
 Obtaining a RequestDispatcher Forwarding requests from servlets to dynamic resources  Forwarding requests from servlets to static resources  Using.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
CSC 2720 Building Web Applications JavaServer Pages (JSP) JSP Directives and Action Elements.
CourseOutline Example & JavaBeans Lec Start with Example Displaying Course Outlines User will select either course “web design & development” or.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
Web Technologies Java Beans & JSP By Praveen Kumar G.
Slides © Marty Hall, book © Sun Microsystems Press 1 Using JavaBeans with JSP Core Servlets & JSP book:
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
© 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.
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.
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.
JAVA SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
JSP in Action. JSP Standard Actions forward, include, useBean, setProperty, getProperty, text, element, and plugin Additional actions param, params,
Chapter 14 Using JavaBeans Components in JSP Documents.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session I: Introduction to Server-Side Web Development with Servlets.
JSP Action Elements Lec - 37.
JSP Based on
Advanced Java Programming
Java Server Pages By: Tejashri Udavant..
Scripted Page Web App Development (Java Server Pages)
USING JAVABEANS COMPONENTS IN JSP DOCUMENTS K. Phani Sirisha
Scope and State Handling in JSPs
JavaBeans and JSP CS-422.
Introduction to Java Bean
Introduction to Java Bean
Java Server Pages B.Ramamurthy.
CS320 Web and Internet Programming Java Beans
Cookies Cookies are small bits of textual information that a Web server sends to a browser and that the browser returns unchanged when later visiting the.
Scope and State Handling in Java Server Pages
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.
Scripted Page Web Application Development (Java Server Pages)
Web Technologies Java Beans & JSP
Presentation transcript:

Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax 24 th February 2005 Bogdan L. Vrusias

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Contents JavaBeans Examples Sessions

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Invoking Java code from JSP Call Java code directly Call Java code indirectly Use beans Use the Model-View-Controller architecture Use the JSP expression language (EL) Use custom tags Simple application or small development team Complex application or large development team

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBeans JavaBeans is a portable (platform-independent) component model written in Java and was developed in collaboration with industry leaders. JavaBeans components are Java classes that can be easily reused and composed together into applications. Any Java class that follows certain design conventions can be a JavaBeans component. JavaServer Pages technology directly supports using JavaBeans components with JSP language elements. JavaBeans will minimize the code on the JSP.

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBeans: Advantages No Java syntax in the JSP –Stronger separation between content and presentation –Good for separating Web and Java developers Simple object sharing –Due to the JSP bean constructs Convenient correspondence between request parameters and object properties –Simple process of reading request parameters

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBeans: Basics A bean class must have a zero-argument (default) constructor. A bean should have no public instance variables (fields). Persistent values should be accessed through methods called setXxx and getXxx (or isXxx for Boolean).

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBeans: Basic Tasks In a JSP there are three main JavaBean constructs: –jsp:useBean –jsp:getProperty –Jsp:setProperty (CAREFUL) Otherwise

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBeans: Basic Tasks Properties of a JavaBean class must simply be accessible using public methods that conform to certain conventions: –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) {... } NOTE: beanName must be the same as that specified in a useBean element (using the id attribute), and there must be a getPName method in the JavaBeans component.

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBean Example I StringBean.java package webtech; public class StringBean { private String message = "No message"; public String getMessage() { return(message); } public void setMessage(String message) { this.message = message; }

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JavaBean Example II StringBean.jsp... Initial value (getProperty): Initial value (JSP expression): Value after setting property with setProperty: Value after setting property with scriptlet:...

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans (Default) –Bean is not shared and a new bean is created for each request –Same as "page" scope but, two JSP pages or a JSP page and a servlet will share the bean when you use jsp:include –Bean is shared within a session –Bean is shared by all servlets and JSP pages in a Web application

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Example This example demonstrates the use of JavaBeans and how the beans are shared. There are four possibilities: –Page –Request –Session –Application For this example these is one JavaBean that stores two parameters, and five JSP pages to demonstrate the use of the bean.

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: The JavaBean BakedBean.java package webtech; public class BakedBean { private String level = "half-baked"; private String goesWith = "hot dogs"; public String getLevel() { return(level); } public void setLevel(String newLevel) { level = newLevel; } public String getGoesWith() { return(goesWith); } public void setGoesWith(String dish) { goesWith = dish; }

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Page Scope Example BakedBeanDisplay-page.jsp … Baked Bean Values: page-based Sharing Bean level: Dish bean goes with: …

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Request Scope Example BakedBeanDisplay-request.jsp … Baked Bean Values: request-based Sharing <jsp:useBean id="requestBean" class="webtech.BakedBean" scope="request" /> Bean level: Dish bean goes with: …

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Request Scope Example BakedBeanDisplay-snippet.jsp Repeated Baked Bean Values: request-based Sharing <jsp:useBean id="requestBean" class="webtech.BakedBean" scope="request" /> Bean level: Dish bean goes with:

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Session Scope Example BakedBeanDisplay-session.jsp … Baked Bean Values: session-based Sharing <jsp:useBean id="sessionBean" class="webtech.BakedBean" scope="session" /> Bean level: Dish bean goes with: …

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Sharing Beans: Application Scope Example BakedBeanDisplay-application.jsp … Baked Bean Values: application-based Sharing <jsp:useBean id="applicationBean" class="webtech.BakedBean" scope="application" /> Bean level: Dish bean goes with: …

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Installing JavaBeans Each JavaBean should be located within your web application under: WEB-INF/classes Or, if the bean is within a package (recommended), then: WEB-INF/classes/subdirectoryMatchingPackageName Or, if the bean is within a.JAR, then place the.JAR in: WEB-INF/lib

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JSP Sessions I A session can be defined as a series of related interactions between a single client and the server, which take place over a period of time. A session object can be used for storing and retrieving information. Every time the client accesses the resources on the server, the client provides the session ID that was assigned by the server. A session has a one-to-one association between a client and the server.

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © JSP Sessions II Session tracking is a technique for maintaining user information across pages: –HTTP information (not used much… privacy issues) –Hidden fields (very popular… but again privacy issues) –Extended Path information and URL-rewriting ( privacy issues) Next –Cookies (data can be encrypted) Cookie uid = new Cookie(“uid”, “234ff543333c”); response.addCookie(uid); –Session (data can be encrypted) session.putValue("user_id", user_id); session.getValue("user_id")

Introduction to Server-Side Web Development 24 th February 2005Bogdan L. Vrusias © Closing Questions??? Remarks??? Comments!!! Evaluation!