Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session I: Introduction to Server-Side Web Development with Servlets.

Slides:



Advertisements
Similar presentations
JSP and Servelets.
Advertisements

Lecture plan Information retrieval (from week 11)
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.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
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.
Introduction to Web Application Architectures Web Application Architectures 18 th March 2005 Bogdan L. Vrusias
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Introduction to Servlet & JSP
Comp2513 Java Server Pages 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.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
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.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Server-side Technologies
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Introduction Servlets and JSP Celsina Bignoli
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
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.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Introduction to JAVA Instructor : Simon Hui & Louis Wong Industrial Centre The Hong Kong Polytechnic University Sep, 2002.
1 Chapter 2 The Web Tier  Web Applications and Web ContainersWeb Applications and Web Containers  Dynamic Content CreationDynamic Content Creation 
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web Development with Servlets and JSP;
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
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.
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.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
MC365 Application Servers, Servlets, and Java Server Pages (JSP’s): Tomcat.
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.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
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.
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.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
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.
Java Servlets and Java Server Pages
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 SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
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.
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.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Introduction to Server-Side Web JavaBeans; basic concepts and syntax.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Java Server Pages Can web pages be created specially for each user?
Introduction Servlets and JSP
Scripted Page Web App Development (Java Server Pages)
Introduction to JSP Liu Haibin 12/09/2018.
MSIS 655 Advanced Business Applications Programming
Chapter 27 WWW and HTTP.
Presentation transcript:

Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session I: Introduction to Server-Side Web Development with Servlets and JSP; basic concepts and syntax 19 th February 2004 Bogdan L. Vrusias

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Introduction Most web sites want to display dynamic content based on user’s requests and expectations. Most contents, such as images, text, and banner ads, are easiest to build with HTML editors. So we need to mix the "static" content of HTML files with "directives" for accessing or generating dynamic content. Introducing:

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Session I History of JSP Fundamentals of server-side programming. Comparison to other server-side languages Fundamentals of JavaServer Pages / Servlets. More Servlets JSP Syntax JavaBeans

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Definition JSP provide server-side scripting support for generating web pages with combined static and dynamic content. JSP is a fast way to serve web pages that display dynamically generated content.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © History: The Beginning 1991… beginning of WWW… beginning of HTML No dynamic pages… the Webmaster Too many static HTML pages had to be created for each website. Need for a change

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © History: First approach - CGI Solution… Common Gateway Interface technology created. Dynamic pages…using Perl and C Problem… these languages are not the simplest Need for a change

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © History: Servlets and JSP Java had the answer… Servlets Servlets are pure Java objects that generate HTML by writing it to a stream. The files do not contain any HTML tags; they simply contain Java code which write out HTML (as strings) to produce the page that is sent to the user's browser. Historically, this used to be the only way to generate dynamic content in Java, but it is quite painful to develop any large scale application with a bunch of servlets running around doing println() statements. This is why Sun invented JSPs in the first place: to compete with the ease-of-development of Microsoft's ASP files, which - you guessed it - could combine HTML tags and code in a single file.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © A dynamic Web Page Static web page is a page whose content consists of some HTML that was predetermined and was typed directly into a text editor and saved as.htm or.html file. Dynamic web page is a page whose content is generated at runtime dynamically. 6. Browser processes HTML and displays page. 2. Client request web page 1. Author writes instructions 3. Web server locates instructions file 4. Web server processes instructions to create HTML 5. HTML stream returned to browser

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Requests and Responses

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Other Server-Side programming languages CGI –Perl, C, C++ ColdFusion –Tags with encapsulated functionality ASP (Active Server Pages) and ASP.NET –VBasic, JavaScript –ADO PHP (Personal Home Pages) –Syntax similar to C and Perl –Open-source, cross-platform

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JSP Vs ASP Similarities –Create interactive pages with web-based applications –Separates programming logic from page design through the use of component technology –Faster and Easier alternative to older, more cryptic technologies such as CGI Differences –JSP: Platform and Server Independent JSP can run on any web server Supported by large number of tools –ASP: Relies on Microsoft Platforms and Servers Restricted to MS Windows based platforms because of ActiveX Controls Can be ported to different platforms using third party products, ActiveX must be present on the platform

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Why Use JSPs? Write once, run anywhere. –JSPs are entirely platform independent, both in dynamic Web pages and underlying server components. Emphasize components. –JSPs encourage the use of reusable, cross-platform server components called JavaBeans. Therefore saves development time, while giving you the power and flexibility of the Java programming language. Provide a front door to the Enterprise’s Java platform. –JSPs are an integral part of the Java Platform for the Enterprise, which brings Java technology to enterprise computing. You can develop powerful enterprise-wide or middle-tier server applications, using a JSP web site as a front end.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Advantages of Java More mature, powerful, and scalable than Basic-based scripting languages Java helps developers protect against system crashes, ASP and NT systems are susceptible to crashing Java helps with memory management by providing protection against memory leaks

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JSP Models Model 1 Model 2

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Servlets Characteristics Security –Servlets are called within the server context so they have all the security of the server itself. –They’re hidden from view and transmission. Robustness –Rich application programming interfaces, APIs, are available to Java programs making it easier to build sophisticated applications in a minimal amount of time (JDBC, EJB, etc.). Performance –Servlets run in the same context as the application server and can be preloaded or loaded on demand. –They’re multi-threaded to scale with multiprocessors and heterogeneous systems Portability –Write-once, run-anywhere capability –They are able to exploit re-useable Java components called JavaBeans.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © How Servlets relate to JSPs 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.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Servlet Code Sample import javax.servlet.*; import java.io.*; import java.util.*; public class SimpleServlet extends GenericServlet { public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); printWriter pw = response.getWriter(); pw.println(" "); for(int counter = 1; counter <= 10; counter++) { pw.println(counter + " Mississippi, "); } pw.println(" Ready or not, here I come! "); pw.println(" "); pw.close(); }

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JSP Code Sample Mississippi, Ready or not, here I come!

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JSP Syntax Directives Declarations Scriptlets Expressions Comments

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Directives Here is what directives look like in a general form: There are three directives: specifies information that affects the page e.g. includes a file at the location of the include directive (parsed) e.g. allows the use of custom tags in the page e.g.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Declarations <%! // this integer can be used anywhere in this JSP page private int myVariable = -1; // this function can be called from anywhere in this JSP page public boolean isPositive() { return ( myVariable > 0 ); } %>

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Scriptlets <% // Java Code %>

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Expressions

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Comments

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © Action Elements There are three different types of action elements: –Standard and –Custom Tags constructed by the developer. –JSTL (JavaServer Pages Standard Tag Library) It provides tag libraries in the subject of: –Internationalization and formatting, XML, SQL, and the core tags.

Introduction to Server-Side Web Development 19 th February 2004Bogdan 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. JavaBeans will minimize the code on the JSP.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JavaBeans Basics JavaServer Pages technology directly supports using JavaBeans components with JSP language elements. You can easily create and initialise beans and get and set the values of their properties. There is no requirement such that a property must be implemented by an instance variable; the property 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) {... } In addition to the property methods, a JavaBeans component must define a constructor that takes no parameters.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JavaBeans Syntax You declare that your JSP page will use a JavaBeans component using either one of the following formats: – The second format is used when you want to include jsp:setProperty statements, for initialising bean properties.

Introduction to Server-Side Web Development 19 th February 2004Bogdan L. Vrusias © JavaBeans Syntax To retrieve a JavaBeans component property you can use either one of the following formats: – beanName must be the same as that specified for the id attribute in a useBean element, and there must be a getPropName method in the JavaBeans component.

Introduction to Server-Side Web Development 19 th February 2004Bogdan 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 19 th February 2004Bogdan 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 19 th February 2004Bogdan L. Vrusias © Session I: Closing Questions??? Remarks??? Comments!!! Evaluation!