Server-Side Development Basics Harry R. Erwin, PhD University of Sunderland CIT304/CSE301.

Slides:



Advertisements
Similar presentations
DT228/3 Web Development WWW and Client server model.
Advertisements

Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
15 Chapter 15 Web Database Development Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
DT211/3 Internet Development Application Internet Development Application.
Introduction to Web Interface Technology (CSE2030)
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.
Definitions, Definitions, Definitions Lead to Understanding.
Introduction to Web Interface Technology (CSE2030)
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
/ department of mathematics and computer sciencedepartment of mathematics and computer science / architecture of information systems.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
8 Server Side Scripting.
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.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
INTRODUCTION TO WEB DATABASE PROGRAMMING
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Applets & Servlets.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Web Applications Harry R. Erwin, PhD University of Sunderland CIT304/CSE301.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
Copyright (c) 2010, Dr. Kuanchin Chen1 The Client-Server Architecture of the WWW Dr. Kuanchin Chen.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
Apache Struts RIFE Ruby on Rails Harry R. Erwin, PhD University of Sunderland CIT304/CSE301.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Running Jakarta/Tomcat CIT304/CSE301 University of Sunderland Harry R. Erwin, PhD.
Chapter 6 Server-side Programming: Java Servlets
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 14 Database Connectivity and Web Technologies.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
MC365 Application Servers, Servlets, and Java Server Pages (JSP’s): Tomcat.
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.
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
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.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Introduction and Principles Web Server Scripting.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Java Servlets and Java Server Pages
Chapter 4 Request and Response. Servlets are controlled by the container.
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 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
Introduction Servlets and JSP
Servlet Fudamentals.
CS122B: Projects in Databases and Web Applications Winter 2018
Introduction to Servlets
CS122B: Projects in Databases and Web Applications Spring 2018
Objectives In this lesson you will learn about: Need for servlets
J2EE Lecture 1:Servlet and JSP
Presentation transcript:

Server-Side Development Basics Harry R. Erwin, PhD University of Sunderland CIT304/CSE301

Resources Hans Bergsten, 2002, JavaServer Pages, 2nd edition, O’Reilly, ISBN: X Farley, et al., 2002, Java Enterprise in a Nutshell, 2nd edition, O’Reilly, ISBN: Brittain and Darwin, 2003, Tomcat: the Definitive Guide, O’Reilly. Kurniawan and Deck, 2004, How Tomcat Works, BrainySoftware.com. Knuckles and Yuen, 2005, Web Applications: Concepts and Real World Design, Wiley. Nakhimovsky and Myers, 2004, Google, Amazon and Beyond, Apress.

Questions to be Answered What is server-side programming (SSP)? What are some approaches to SSP? What are SSP basics? What is JSP? How can I support SSP?

What is Server-Side Programming (SSP)? Technologies for developing web pages that include dynamic content—that is web applications. Can produce web pages that contain information that is connection- or time-dependent. A key technology for on-line shopping, employee directories, personalized and internationalized content.

History of Dynamic Web Content The Common Gateway Interface (CGI) was the first approach to providing dynamic web content. Used scripts, and a process, not just an individual thread, was dispatched for each web page generated. Hence inefficient and did not scale well. Numerous second generation alternatives were invented: –FastCGI –mod_perl –NSAPI –ISAPI –Java Servlets These embedded HTML in programming code. Hence costly in programmer time.

Scripting—the Third Generation Approach Idea: embed simple code in HTML pages! The HTML pages then use the code to choose what elements and data to display. Classes and/or subroutines may be called to compute information for inclusion in the web page. Existing APIs can be invoked. This is known as ‘scripting’.

Some Approaches to Scripting JavaServer Pages (JSP, uses Java sparingly, will be covered in these lectures) Active Server Pages (ASP, uses VBScript, Jscript, COM or ActiveX components, ODBC). ASP.NET is quite similar to JSP, using C#. Has not been very popular. PHP (C-like syntax, many functions available, insecure, covered in DL versions of CIT304) ColdFusion (CFML, proprietary) Java servlet template engine (Velocity, FreeMarker) Not much change in the last five years, other than the introduction of AJAX (JavaScript + XML).

Some JSP Basics The HTTP protocol. Servlets

The HTTP Protocol A communications model: –A client, often but not always a web browser, sends a request for a resource to a server. –The server returns a response or an error message. Points to remember: 1.Stateless protocol. 2.Delayed feedback. 3.Server cannot tell how the request was made. No client-side processing can be invoked. (If it could be, it would be a security nightmare.)

Examples of HTTP Clients Web browsers (many, including specialized ones for console interfaces—lynx—and handicapped users) Search utilities (Sherlock on MacOS X) Help utilities FTP clients (e.g., interarchy on MacOS X) Software registration programs telnet (a hacker can emulate a web browser by connecting to port 80) Specialized programs (e.g., curl) Cracker toolkits (to generate malformed http requests)

HTTP Requests Information is specified by an HTTP Uniform Resource Locator (URL, see RFC-2396 and RFC- 2616). Consists of: –Protocol designation (http and https) –Server name:port number (port number defaults to 80 for http and for https) –Name of the resource being requested. Need not be a file. Here it is: /~cs0her/index.html

HTTP Request Message Consists of: –Request line GET resource_name protocol_in_use POST (provides parameters in the request body, see below) –Request headers Host (server name) User-Agent (browser type) Various Accept headers describing formats and languages –Request body (optional)

Java Servlets Currently, Java is the predominant language for SSP. This is due to the Java Servlet API. Advantages over other SSP technologies: –Persistent between invocations, avoiding process instantiations. –Portable across operating systems and servers. –Good security. –Can use the Java APIs, particularly JDBC. –Is integrated closely with the J2EE environment.

Servlets A servlet runs in a servlet container within a Java Virtual Machine. Servlet containers: –Apache/Jserv, which supports Servlets 2.0. –Mortbay.com/Jetty –IBM/WebSphere –Jakarta/Tomcat 4.0 (This is the reference implemen- tation for the Servlet 2.3 API). Available from We will discuss Tomcat in a later lecture.

Servlet Basics The Servlet API consists of two Java packages: –javax.servlet –javax.servlet.http Required for J2EE 1.3

Servlet Lifecycle A client makes a request involving a servlet running on the server. The servlet is responsible for loading and executing the Java classes that generate the HTML content. To the client, this looks like standard HTML processing, except faster. The servlet then need not shut down. Instead, it can handle subsequent requests without restarting.

Servlet Methods init(), to handle startup. Once init() runs, the servlet is available. service() is called to process each request. Disk writes are only needed to preserve state. Arguments to service() are ServletRequest and ServletResponse objects. destroy() is called to clean up resources when the server shuts down (if it ever shuts down).

Core of the API javax.servlet.Servlet interface. javax.servlet.http.Servlet class, implementing the interface. Designed to work with the HTTP protocol. javax.servlet.GenericServlet class, implementing the interface. This class is communication protocol agnostic. Can implement a filtering servlet to adapt output from some other source. This can provide other protocol services (e.g., ftp).

A Web Application A set of resources (servlets, static content,.jsp files, class libraries) installed in a specific path, making up a directory. Should be organized as a chroot jail. Multiple servlets can exist concurrently. Run in a common ServletContext. Be careful—the path can change from machine to machine.

Supporting JSP Requirements: –Workstation or PC with an internet connection. –Java 2 SDK (available from Sun, links on my COM379 handbook page) –JSP 1.2-enabled web server such as Apache Tomcat (Jakarta Project). This is available here at the Informatics Centre.

Sounds Good? Not really—Java servlets have to be programmed and their configuration must be managed. Programmers make $50,000-$90,000 in the USA, and programs are notoriously hard to develop and maintain. This is particularly a problem when changes to business logic force changes. Next lecture: we will look at how the same thing can be done more quickly, easily, and flexibly with web pages.

Conclusions You’ve gained a general understanding of what Server Side Processing (SSP) is. You’ve seen the role of SSP in HTTP processing. You’ve been introduced to Java Servlets, and You now know the basic configuration for servlet processing. Next lecture, you will see how JavaServer Pages (JSP) interact with this environment.