Servers- Apache Tomcat Server Server-side scripts- Java Server Pages Java Server Pages - Xue Bai.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Lecture plan Information retrieval (from week 11)
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to JavaScript
Servlets Enterprise Systems Programming. Servlets  Servlets: server-side Java programs that enable dynamic processing of web-based requests  Web-based.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Lesson 4 Advanced Forms Handling. Aggravations Long forms that make you scroll out of the normal viewing area Lets create a scrollable form that is a.
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
HTML Markup language - controls appearance and content of a document Javascripts Various HTML tags.
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Multiple Tiers in Action
Apache Tomcat Server Typical html Request/Response cycle
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Contrast with JavaScript HTML Formsto invoke Java Server Pages Structure of Forms Query strings Java Server Pages Sent From Browser To Serverfor JSP.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Inline, Internal, and External FIle
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Tomcat Celsina Bignoli History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
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.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
© 2011 Delmar, Cengage Learning Chapter 9 Collecting Data with Forms.
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
Software Requirements Specification (SRS)
Movie Manager by Patrick Wesley and Chris Grey Internet Database Project for CS 8630 – Summer 2004 Dr. Guimaraes.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
JSP Java Server Pages Softsmith Infotech.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
Jsp (Java Server Page) Is a server side program.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
IT WEB TECHNOLOGY Prepared by, K.ABINAYA Lect/IT.
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.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
JSP Server Integrated with Oracle8i Project2, CMSC691X Summer02 Ching-li Peng Ying Zhang.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
Web Programming Introduction to Web Technology HTML & Dynamic web content.
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
Display Page (HTML/CSS)
 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,
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
Week-12 (Lecture-1) Cascading Style Sheets (CSS): describe how documents are presented on screens. Types of Style Sheets: External Style Sheet - Define.
How the Web Works? WWW use classical client / server architecture
Introduction to Dynamic Web Programming
Development of Web Applications - Introduction
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
Introduction and Principles
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
JavaScript Client-side
Java Web Application Framework
FORM OBJECT When creating an interactive web site for the Internet it is necessary to capture user input and process this input. Based on the result of.
Common Page Design Elements
Client-Server Model: Requesting a Web Page
Presentation transcript:

Servers- Apache Tomcat Server Server-side scripts- Java Server Pages Java Server Pages - Xue Bai

Objectives What is Request/Response protocol for a client-side script What is Request/Response protocol for server-side script How does server interact with multiple concurrent clients How can html meta-tags control request/response interaction How does effect depend on file extension - html versus jsp

I: client-side, server-side,.jsp, JavaScript form screening, JSP results, multi-threaded server responses, Html meta-tag refresh, need for.jsp versus.html extension, JSP’s conditional generation of Html, forms, buttons, onClick event, JavaScript function, reset, role of names on forms to identify form elements, table definition, textfields, alert pop-up window, configuring for Apache Tomcat server, Class & ClassPath system environment variables, <script & <% tags for JavaScript & JSP II: form - events - extend form, \myjspapp\chapter02\example14.html, qualified names for elements, submitting form data, request/response cycle[38], GET method:processing by server-side program, submit button, method identification, how element names are used, how JSP program accesses form element values, run: chapter03\example6a.html example - note query string sent to server - in address field of browser - after submit clicked - un-highlight beforehand so visible, focus attention, request.getParameter method, JSP Html dynamic output, dynamic html example: 12a contrast Netscape & IE & 12b Topics

client 1. requests URL for html page server 2. retrieves html page 3. sends html page to client 4. browser interprets html page & displays Typical html Request/Response cycle

Request/Response for page - JavaScript commands client 1. requests URL for html page server 2. retrieves html page 3. responds w. page to client 4. interprets page - (browser) executes Java script commands eg: check for bad or missing data on form with embedded JavaScript commands CLIENT-SIDE SCRIPT (Apache Tomcat)

4. interprets page - Request/Response for page - with JavaScript commands executes Java script Commands client server 3. sends page to client 1. requests page 2. gets page

1 - requests JSP page server 2 - retrieves page 3 - responds with html+results in page browser executes server-side script may have embedded JSP server script & Java-client-Script Request/Response for file with Java Server Page parts SERVER-SIDE SCRIPT

Request/Response for Java Server Page client 1. sends URL for JSP page server 2. retrieves page from storage 3. sends html + results to client 4. browser displays page executes JSP code replaces code with exec results * compiled first time only - thereafter uses compiled copy experiment on effect of extensions like.jsp or.html compiles embedded JSP code *

2 - retrieves page using URL addr & server configuration 1 - requests JSP page server 3 - responds & html + results browser executes client-side script executes server-side script Context path="/myapp" docBase="c:\myjspapp"

Experiment: JSP versus JavaScript - client v. server execution 1. Start Apache Tomcat server listening on port 8080 localhost 2. Request a Java Server page from server - source file will have Results 3. Request html page with JavaScript - source page will have the JavaScript [at least in Explorer - not Netscape] 2. C:\myjspapp\chapter01\example2.jsp 3. C:\myjspapp\chapter02\example2a.html – prev slide Start Tomcat server from start Menu or shortcut on desktop

current server time The current Date and time on the web server are: Request for JSP.jsp page retrieved is: embedded jsp instruction jsp instruction - executed on "server-side" - result replaces code C:\myjspapp\chapter01\example2.jsp

1. Request this page from server which is Listening on port Contents sent by server - after executing jsp code located in requested file

current server time The current Date and time on the web server are: Wed Nov 27 20:27:02 EST "source" as shown in browser 2. Note how Date’s Result replaces original JSP in page sent to browser

sent to browser and executed on browser requested source page is same as displayed in browser Request for Java Script page Client-side script THE TIME ON THE CLIENT IS: Current time is: document.write (new Date() ) C:\myjspapp\chapter02\example2a.html Request from server - versus drag-and-drop in browser - observe address bar Why not executed on server ?

JavaScript Request response displayed in browser Source shows only JavaScript code - not the computed date

How can a server interface with multiple client browsers simultaneously ? Ans: creates multiple threads - one per browser. Experiment: JSP with refresh meta-tag from multiple browsers Use URL: Source contains Html Meta tag: and JSP instruction:

server-side scripts The time on the server is: JSP page requested is: requested every 5 sec from current directory of original request JSP result replaces this code & is sent to browser URL:

IP address of server port that server listens on Requested File’s address on the server remainder of file address path server uses configuration file to convert this to initial part of path: " 8080/myapp/ WHEREWHICH WHAT C:\myjspapp

What happens if you request an html page that has embedded JSP ?

-- effect of EXTension on how server handles request: Effect of suffix: versus Source html contains Java Server Page instructions - java inside jsp tags: <% java.util.Calendar calendar = java.util.Calendar.getInstance( ); int hour = calendar.get(calendar.HOUR_OF_DAY); if ( hour Good morning! Good afternoon! JSP...it would be better to just use print statement – this looks confusing.

Welcome to JSP <% java.util.Calendar calendar = java.util.Calendar.getInstance(); int hour = calendar.get(calendar.HOUR_OF_DAY); if ( hour < 12) { %> Hour is Good morning! Good afternoon! project3.jsp versus same file with different extension: project3.html HTML – green JSP – red / blue JSP starts/stops with Html can occur anywhere else

Page displayed for project3.jsp: Good afternoon! Welcome to Introduction to JSP In this chapter, you: learned about Web client/server architecture learned the difference between static and dynamic Web pages learned how dynamic Web pages are generated in JSP reviewed various server-side processing technologies compared JSP to alternate time-dependent jsp output

Displayed page For project3.html IE browser - no result (and no JSP shown) Good morning! Good afternoon! Welcome to Introduction to JSP In this chapter, you: learned about Web client/server architecture learned the difference between static and dynamic Web pages learned how dynamic Web pages are generated in JSP reviewed various server-side processing technologies compared JSP to alternate technologies

Netscape - no result (JSP shown) <% java.util.Calendar calendar = java.util.Calendar.getInstance(); int hour = calendar.get(calendar.HOUR_OF_DAY); if( hour Good morning! Good afternoon! Welcome to Introduction to JSP In this chapter, you: learned about Web client/server architecture learned the difference between static and dynamic Web pages learned how dynamic Web pages are generated in JSP reviewed various server-side processing technologies compared JSP to alternate technologies Displayed page project3.html

Java Server Pages - II

How does request/response protocol operate for forms & jsp pages How do you submit form data to server using GET method? Objectives - Understand How to configure a (Tomcat) server How do you dynamically construct Html using Java Server Pages What is the URL format How do JSP programs get data from forms

How do you submit form data to server using GET method? C:\myjspapp\chapter03\example6a.html C:\myjspapp\chapter03\getUserInfo.jsp

Experiment: demonstrates submitting and retrieving form data using GET method 1. chapter03/example6a.html sends data via GET 2. chapter03/getUserInfo.jsp uses request object request.getParameter (... ) to retrieve named data from form

Request/Response protocol 2. retrieve html form browser 4. display form - user enters data & submits form 6. triggers retrieving, compiling getUserInfo.jsp referred to on form - executes jsp with data from query-string 1. request html page example6a.html 3. returns form 7. returns results to client 5. sends URL +query-string chapter03\example6a.html server understand thoroughly

Submit using GET Method Please sign Your Name: Your Major: THE TIME ON THE CLIENT IS: document.write (new Date( ) ) example6a.html jsp program executed on Submit triggers submission of query string to server GET sends data in query-string data names

Query string sent by browser to server: ? firstName=aaa&major=zzz jsp to executedata for program SERVERPROGRAMDATA FOR PROGRAM WHEREWHOWHAT

get User information Hi there - how are you? Your major is: Your name is: The current Date and time on the web server are: getUserInfo.jsp retrieves values entered on form which are returned in query string field names on html form that triggered execution of getUserInfo.jsp

get User information Hi there - how are you? Your major is: Your name is: The current Date and time on the web server are: getUserInfo.jsp ? firstName=aaa&major=zzz DATA FOR PROGRAM

C:\myjspapp\chapter01\filename so file retrieved is: replaced with C:/myjspapp because of server configuration Requested file on serverServer IP Interpretation of URL port The context prefix myapp makes the web site Relocateable. You just change myapp to point to the directory where site pages begin.

How do you configure the Tomcat server ?

Environment setup 1. control panel > system > advanced > environment variables > system variables %SystemRoot%\system32;%SystemRoot%; %SystemRoot%\System32\Wbem; C:\jdk1.2.2\bin...on one line points to JDK bin update PATH variable to include JDK 2. similarly add CLASSPATH system variable defined as : C:\jdk1.2.2\jre\lib\rt.jar;.; C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar; C:\myjspapp\WEB-INF\CLASSES …all on a single line Assumes jdk same idea for other versions of jdk.

Environment setup 1. start > all programs > Apache Tomcat 4.0 > Edit Configuration file right after: <!-- --> add: <Context path="/myapp" docBase="c:\myjspapp" debug="0" reloadable="true" /> 1. this 2. gets expanded to this

Environment setup 1. start > all programs > Apache Tomcat 4.0 > Edit Configuration file add: <Context path="/myapp" docBase="c:\myjspapp" debug="0" reloadable="true" /> If user wants: C:\myjspapp\chapter03\example6.html then asks for:

What are the advantages of using a client-side versus server-side script ? Client-side script can prevent bad data being sent to server which would waste user’s time, server’s time, and waste communication resources Server-side script allows protected server-side access to data on the server side.

jsp output Hello " %> How are you? <% out.println ( " Goodbye " ); %> 1. as quoted html example10a.jsp 2. as direct html 3. in print statement Different ways JSP can output HTML:

chapter03/example12a.html Form => name & font fields => JSP program => returns dynamic html

font effect Please sign Font size: Type name: chapter03/example12a.html Form

get User information Hi there - how are you? <% out.print ("<font size = "); out.print (request.getParameter("font")); out.print (" color = blue>"); out.print (request.getParameter("Name")); out.print (" "); %> chapter03/getFontEffect.jsp JSP page triggered by form: This builds font statement: Name.value

get User information Hi there - how are you? <% out.print("<font size = "); out.print( request.getParameter("font") ); out.print(" color = "); out.print( request.getParameter("colorName") ); out.print(">"); out.print( request.getParameter("Name") ); out.print(" "); %> make the font tag prefix font text font tag suffix used as color [blue, red...] used as text [double use] chapter03/getFontEffect2.jsp Variation [uses Name as color choice]

JSP control structure and Html Experiment: Retrieve font values from an HTML form & return name in font depending on hour of day 1. chapter03/example12b.html => returns form 2. chapter03/ifThenElseHtml.jsp => returns time-sized name

font effect Please sign Your Name: Select font: chapter03/example12b.html requested JSP program

chapter03/ifThenElseHtml.jsp time-based display Hi there - how are you? <% java.util.Calendar date = java.util.Calendar.getInstance(); int hour = date.get(date.HOUR_OF_DAY); if (hour <= 15) { out.print ("<font size = "); out.print (request.getParameter("font")); out.print (" color = blue>"); out.print (request.getParameter("Name")); out.print (" "); }else { out.print ("<font size = 10"); out.print (" color = red>"); out.print (request.getParameter("Name")); out.print (" "); } %> Link Illustration

time-based display Hi there - how are you? <% java.util.Calendar date = java.util.Calendar.getInstance(); int hour = date.get(date.HOUR_OF_DAY); if (hour <= 15) { out.print ("<font size = "); out.print (request.getParameter("font")); out.print (" color = blue>"); out.print (request.getParameter("Name")); out.print (" "); } else { out.print ("<font size = 10"); out.print (" color = red>"); out.print (request.getParameter("Name")); out.print (" "); } %> Link Illustration