Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.

Slides:



Advertisements
Similar presentations
Apache Tomcat as a container for Servlets and JSP
Advertisements

Java Server Pages (JSP)
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.
 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.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
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.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
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,
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Introduction to Servlet & JSP
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
CSCI 6962: Server-side Design and Programming History and Background.
Java Servlets and JSP.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Server-side Technologies
Introduction Servlets and JSP Celsina Bignoli
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Introduction to Java Server Pages (JSPs) Robert Thornton.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
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,
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
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.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Java Servlets Java Server Pages (JSP)
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Java Servlets and Java Server Pages
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,
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.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
CS122B: Projects in Databases and Web Applications Spring 2017
CS122B: Projects in Databases and Web Applications Winter 2017
Introduction Servlets and JSP
Servlet Fudamentals.
HTTP Servlet Overview Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might.
MSIS 655 Advanced Business Applications Programming
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
J2EE Lecture 1:Servlet and JSP
CS122B: Projects in Databases and Web Applications Winter 2019
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.

Contents  Overview  History  CGI vs. Java Servlet  Java Servlet vs. JSP  How Servlet Works  Servlet Example  How JSP Works  JSP Container  JSP Constructs and Examples  Online Resources

Overview(1/3)  What is servlet?  Servlet is platform-independent, server-side Java component which extend an HTTP server  Like mini web server  HttpServlet – Dynamic page generation(HTML, XML,...)  Superior to inefficient CGI and proprietary APIs(ISAPI, NSAPI,...)

Overview(2/3)  What is JSP(Java Server Page)?  JSP separates content presentation from content generation  Provides a simple and fast way to build dynamic page content(HTML, XML, etc)  HTML with embedded Java code  Extensible with components & custom tags  JSP and ASP  similar, but the differences are  ASP is based on MS-specific technologies such as IIS, Visual Basic  JSP can be applied to much more platforms such as Solaris, Linux, FreeBSD without any kind of code-level conversion

Overview(3/3)  The J2EE Architecture

History(1/2)  History of Java Servlet  Sun introduced Java Servlet in 1996  Java Servlet Developers Kit released in 1997  J2EE 1.3 beta released in 2001, which contained servlet 2.3  J2EE 1.4 released in 2005, which contained servlet 2.4

History(2/2)  History of JSP  James Gosling’s work on a Web Server in Java in 1994/1995 became the foundation for servlets  A larger project emerged in 1996 with Pavani Diwanji as lead engineer  The JSP group, with Larry Cable and Eduardo Pelegri-Llopart as leads, delivered JSP 1.0 in 1999 June and JSP 1.1 in 1999 December  The JSP 1.2 specification went final in 2001, which added the ability for validating JSP pages through the XML views of a JSP page  JSP 2.0 released in 2003, which included a simple Expression Language, tag files, substantial simplifications for writing tag handlers in Java and the notion of JSP fragments

CGI vs. Java Servlet(1/2) CGI  Earliest technology used for dynamic web generation  HTTP requests are served by programs written in C, C++, Perl etc.  It has drawback of creating separate process for each user request  Lack of Scalability Java Servlet  Java classes are loaded dynamically to expend server functionality  Requests are efficiently handled by threads

CGI vs. Java Servlet(2/2) Browser 1 Web Server CGI 1 Browser 2 Browser N CGI 2 CGI N CGI Web Server Servlet Web Client Servlet HTTP Request HTTP Response Servlet API

JSP and Servlet  JavaServer Pages are based on Servlet technology  JSP container is a Servlet  Each JSP is compiled into runtime Servlet  Same performance and portability benefits from Servlet technology but with the ease of use of markup language  Best of both worlds for web designers and web developers

How Servlet Works doGet() { Process request from Client using Request object; Send response to client via the Response object; } Request Response Http Client Session

Servlet Example(1/3) javax.servlet.Servlet javax.servlet.GenericServlet javax.servlet.http.HttpServlet public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.setContentType(“text/html”); out.println(" "); out.println(” Hello There! "); out.println(" "); out.close(); } your servlet

Servlet Example(2/3) public class FormServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.setContentType(“text/xml”); out.println(" "); out.println(" ”); out.println(“ Bob ”); out.println(" ”); out.println(" ”); out.close(); }

Servlet Example(3/3)  Results HelloServletFormServlet

How JSP Works Java Compiler Servlet Runner JSP Translator JSP Source Hello.jsp Generated file Hello.java Servlet class Hello Output of Hello HTML /XML JSP runtime

JSP Container  Servlet/JSP requires a Container  Apache Tomcat is the reference implementation of the Servlet/JSP Specs  It is open source, small, install quickly,and is FREE  Web Site:  It include a simple HTTP 1.1 server, good enough for development and small intranets

JSP Constructs and Examples  JSP Constructs  Comment  Declaration  Expression  Scriptlet

JSP Constructs and Examples – Comment  Generates a comment that is sent to the client  Comment Types  HTML Comment:  JSP Comment:  Java Comment: // comment, /* comment */  Example <% // Java Comment /* Java Comment */ %>

JSP Constructs and Examples – Declaration  Declares a variable or method  Syntax   Example <%! boolean isSameString(String a, String b) { return a.equals(b); } %> bjlee and hjk is same string

JSP Constructs and Examples – Expression  Scripting language expression that is evaluated and converted to ‘String’  Syntax   Example <% for (int i = 0; i < 10; i++) { %>, <% } %>

JSP Constructs and Examples – Scriptlet  Contains a code fragment valid in the page  Syntax   Example <% String name = “Byung-Joon Lee”; StringTokenizer st = new StringTokenizer(name, “ “); while ( st.hasMoreTokens() ) { %> <% } %>

Online Resources  The Java Programming Language Second Edition, Ken Arnold and James Gosling, Addison-Wesley  Online Courses - Tutorials & Training: Beans,  JSP Core Syntax reference for Tomcat