Introduction Servlets and JSP

Slides:



Advertisements
Similar presentations
Java Server Pages (JSP)
Advertisements

Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
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:
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
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.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Server Side Programming Web Information Systems 2012.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Java Servlets and JSP.
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
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.
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.
Applets & Servlets.
Introduction to JAVA Instructor : Simon Hui & Louis Wong Industrial Centre The Hong Kong Polytechnic University Sep, 2002.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Website Design Lecture 1. Outline Introduction to the module Outline of the Assessment Schedule Lecture Static XHTML, client side and server side Why.
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.
Java Servlets. Servlets When we run small Java programs within a browser these are referred to as Applets... And when we run small Java programs within.
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
Java Servlets and Java Server Pages Norman White Stern School of Business.
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.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java Servlets and Java Server Pages
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
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.
Distributed Web Systems Java Servlets Lecturer Department University.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Java Server Pages Can web pages be created specially for each user?
CS122B: Projects in Databases and Web Applications Spring 2017
CS122B: Projects in Databases and Web Applications Winter 2017
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.
Introduction and Principles
Net-centric Computing
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Introduction to Java Servlets on Jakarta Tomcat
PHP / MySQL Introduction
MSIS 655 Advanced Business Applications Programming
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Java Servlet Ziad A. Al-Sharif.
CS122B: Projects in Databases and Web Applications Winter 2018
Introduction to Servlets
Java Server Pages (JSP)
CS122B: Projects in Databases and Web Applications Spring 2018
IntroductionToPHP Static vs. Dynamic websites
Java Servlets and JSP.
CS122B: Projects in Databases and Web Applications Winter 2019
Basic servlet structure
Web Application Development Using PHP
Presentation transcript:

Introduction Servlets and JSP Celsina Bignoli bignolic@smccd.net

Dynamic web pages Content may change based on identity of the user user’s browser type information provided by the user selections made by the user

CGI CGI (Common Gateway Inteface) CGI scripting is not efficient outlines how a web server communicates with a program. Typically written in Pearl (or C) CGI scripting is not efficient for every request the web server has to create a new process load an interpreter run the program and dispose of the process once done.

CGI improvements Fast-CGI mod_perl, NSAPI, ISAPI runs program in a external process or pool of processes mod_perl, NSAPI, ISAPI run server-side programs in the same process as the web server available only on some web servers

Servlets Server side Java programs Solve scalability issue serlvets are run on threads of execution not separate processes Solve portability issue runs on every platform that supports Java supported by all most popular web servers Issue html tags are embedded in java programs within out.print() statements

JSP server-side technology separate dynamic content from static content of a page Java scriptlets embedded into html-like page Separate the work of java programmers page authors Servlets are server-side Java programs that extends the functionality of a server and can be used to generate dynamic web pages. Compared to competing technologies, such as CGI scripts they offer several advantages: Being written in Java, Servlets are portable across operating systems. In traditional CGI, for every request, the web server has to create a new operating-system process, load a Perl interpreter, load the script code, execute the script, and then terminate the process once it is done. Servlets use Java multithreading so that N simultaneous requests are handle by N concurrent threads of execution within a single process. Servlet remains in memory after servicing a request making it possible to store data between requests. However Servlet technology suffer from a problem: since Servlets are Java programs, HTML tags must be embedded inside the Java code. If you've ever looked at the code for a servlet, you've probably seen endless calls to out.println( ) that contain scores of HTML tags. This approach makes writing and maintaining Servlet rather tedious and error prone. JSP was desined to solve this issue. JSP is an abstraction over the concept of a Servlet that allows the generation of dynamic web content but keeping separated the java code that produces the content form the HTML code that defines its presentation.

JSP relationship to Servlets A JSP is converted into a Servlet What is the relationship between JSP and Servlets? Behind the scenes aJSP page is transformed into a Servlet. From a technical point of view JSP does not provide new core technology - everything that can be done with a JSP page, can also be done by writing a servlet.

Servlet Example embedded HTML import java.text.*; import java.util.*; public class DateServlet extends HttpServlet{ public void doGet(HTTPServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(“text/html’); PrintWriter out = response.getWriter(); out.println(“<html>”); out.println(“<head><title><Date Example</title></head>”); out.println(“<body>”); out.println(“Today is: “); Date d = new Date(); out.println(“<em>” + DateFormat.getInstance().format(d)+ “</em>”); out.println(“</html>”); } embedded HTML The example shows a simple JSP that prints out the current date. You notice it consists of a mix of HTML elements and JSP elements some of which are directives like the import on the first line other are called scriptlets and are used to embed Java code. A JSP page is stored in its textual form on the web server, in a way much similar to HTML pages.

JSP Example Static: HTML/XML elements Dynamic: scriptlets JSP tag <%@ page import=“java.text.*’, java.util.*”%> <html> HTML <head><title><Date Example</title></head> <body> <% Date d=new Date(); String today = DateFormat.getInstance().format(d); %> Scriptlet Today is: <em><%=today%></em> </body> </html> The example shows a simple JSP that prints out the current date. You notice it consists of a mix of HTML elements and JSP elements some of which are directives like the import on the first line other are called scriptlets and are used to embed Java code. A JSP page is stored in its textual form on the web server, in a way much similar to HTML pages. Example.jsp Static: HTML/XML elements Dynamic: scriptlets Additional: special JSP elements

JSP alternatives Active Server Pages PHP ColdFusion allows you to add VBScript or JScript code to the page primarily a solution for te Windows platform PHP open source web-scripting language. extensive set of predifined functions to access databases, LDAP directories, mail servers etc… widely supported ColdFusion ColdFusion Markup Language(CFML) accessing databases, files, mail servers etc… custom elements can be developed in C++ or Java

JSP Unique Features JSP is a specification, not a product competing implementations integral part of J2EE access all features of the Java language

How to get Started Install JDK 5.0 Download Apache Tomcat 5.5 from: www.apache.org Use a regular editor or an IDE that supports JSP development Eclipse JBuilder JCreator Oracle JDeveloper NetBeans Macromedia DreamWeaver