Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias

Slides:



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

JSP and Servelets.
Java Server Pages Jeffrey Jongko. Introduction Java Server Pages (JSP) technology was created by Sun Microsystems and is built on top of Sun’s Java Servlet.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
Chapter 81 JavaBeans JavaServer Pages By Xue Bai.
 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.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
DT211/3 Internet Application Development JSP: Processing User input.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
EE448: Server-Side Development Slide 1 EE448: Server-Side Development Lecturer: David Molloy Time: Tuesdays 3pm-5pm Notes:
MC365 Application Servers: Java Server Pages (JSP’s) and Session Management.
Comp2513 Java Server Pages Daniel L. Silver, Ph.D.
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.
JavaServer Pages TM Introduce by
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
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.
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.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
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.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
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,
Chapter 10 Overview of JSP Technology. Understanding the need for JSP JSP technology enables to mix regular, static HTML with dynamically generated content.
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.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
Chapter 6 Server-side Programming: Java Servlets
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
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.
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.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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:
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.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
© 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.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
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.
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.
Apache Struts Technology A MVC Framework for Java Web Applications.
CS320 Web and Internet Programming Web Application and MVC Chengyu Sun California State University, Los Angeles.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session I: Introduction to Server-Side Web Development with Servlets.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax.
Java Server Pages By: Tejashri Udavant..
Scripted Page Web App Development (Java Server Pages)
MSIS 655 Advanced Business Applications Programming
Java Server Pages B.Ramamurthy.
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.
Presentation transcript:

Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Contents Java Collections API and Casting JavaBeans – Final Remarks Session Tracking

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Java Collection API Array Vector Hashtable ArrayList LinkedList... import java.util.*;

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Array Example int[] anArray; anArray = new int[10]; for (int i = 0; i < anArray.length; i++) { anArray[i] = i; System.out.print(anArray[i] + " "); } boolean[] answers = { true, false, true, false }; MyObject[] anObjectArray = new MyObject[5];

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Multidimensional Array Example int[][] aMatrix = new int[4][]; for (int i = 0; i < aMatrix.length; i++) { aMatrix[i] = new int[5]; for (int j = 0; j < aMatrix[i].length; j++) { aMatrix[i][j] = i + j; } for (int i = 0; i < aMatrix.length; i++) { for (int j = 0; j < aMatrix[i].length; j++) { System.out.print(aMatrix[i][j] + " "); } System.out.println(); }

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Vector Example Vector v = new Vector(); v.addElement("Hello"); v.addElement(new Integer(99)); v.addElement(99); // Error for (int i=0; i < v.size(); i++) System.out.println(v.elementAt(i)); // or v.get(i) Integer a = (Integer) v.elementAt(1);

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Hashtable Example Hashtable nums = new Hashtable(); nums.put("one", new Integer(1)); nums.put("two", new Integer(2)); Integer n = (Integer)nums.get("two"); if (n != null) { System.out.println("two = " + n); } for (Enumeration e = nums.keys (); e.hasMoreElements ();) { System.out.println (e.nextElement ().toString ()); } if (nums.containsKey ("one")) {...}

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © Java Type Conversion / Casting If v is a Vector type collection object then: Getting a String from Vector String s = (String)v.elementAt(x); Vector of Vector objects Vector v = (Vector)v.elementAt(x); Getting a String from Vector of Vector objects String s = ((Vector)v.elementAt(x)).elementAt(y).toString();

Introduction to Server-Side Web Development 10 th March 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 10 th March 2005Bogdan L. Vrusias © Servlets vs. JSP JSPs and servlets are two different ways to accomplish the same goal: generating dynamic HTML pages using Java code. One puts Java code in your HTML, and one puts HTML in your Java code. Functionally, they are equivalent. In fact, under the covers, the web server takes a JSP and converts it to the corresponding servlet and dynamically compiles it. BUT servlets have the following deficiencies: –It is hard to write and maintain the HTML –You cannot use standard HTML tools –The HTML is inaccessible to non-Java developers

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © JSP Example Hello World The date is: <% dateBean.setDate("9-Mar-2005"); %> The new date is:

Introduction to Server-Side Web Development 10 th March 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.

Introduction to Server-Side Web Development 10 th March 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 JavaBeans will minimize the code on the JSP.

Introduction to Server-Side Web Development 10 th March 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 10 th March 2005Bogdan L. Vrusias © JavaBean Example II StringBean.jsp

Introduction to Server-Side Web Development 10 th March 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 10 th March 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 10 th March 2005Bogdan L. Vrusias © JSP Sessions II Session tracking is a technique for maintaining user information across pages. Unsecured / Not recommended: –HTTP information (not used much… privacy issues) –Hidden fields (very popular… but again privacy issues) –Extended Path information and URL-rewriting ( privacy issues) Next

Introduction to Server-Side Web Development 10 th March 2005Bogdan L. Vrusias © JSP Sessions III More secure / Recommended: –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 10 th March 2005Bogdan L. Vrusias © Closing Questions??? Remarks??? Comments!!! Evaluation!