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.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Servlets and Java Server Pages.
Advertisements

CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
M-V-C for web applications. Model for Web Applications model consists of data and system state database tables –persistent data session information –current.
CS4273: Distributed System Technologies and Programming I Lecture 11: JavaServer Pages (JSP)
Apache Tomcat as a container for Servlets and JSP
Java Server Pages (JSP)
Java Servlets Java Server Pages (JSP)
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.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
An introduction to Java Servlet Programming
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.
CS320 Web and Internet Programming JSP Scripting Elements and Page Directives Chengyu Sun California State University, Los Angeles.
JSP Java Server Pages Reference:
Servlets and Java Server Pages Object-Oriented Programming V Written by: Haytham Allos (Instructor) New York University (NYU)
DT228/3 Web Development JSP: Directives and Scripting elements.
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,
Introduction to Servlet & JSP
Three types of scripting elements: 1.Expressions 2.Scriptlets 3.Declarations Scripting elements.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
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.
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.
Servlet and JSP Programming: An Introduction Spiros Papadimitriou
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
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
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.
Netbeans – jsp.zip Introduction to JSP Netbeans – jsp.zip.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
JSP Java Server Pages Softsmith Infotech.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
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 SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Slides © Marty Hall, book © Sun Microsystems Press 1 JSP Scripting Elements Core Servlets & JSP book:
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
JSP Presented by K.Venkata Ratnam HOD MCA (Dept) Newton’s Institute of Engineering.
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.
Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.
Chapter 11 Invoking Java Code with JSP Scripting Elements.
Java Servlets and Java Server Pages Norman White Stern School of Business.
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.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
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.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
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
 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,
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.
Apr 3, 2013 JSP Java Server Pages. 2 A “Hello World” servlet (from the Tomcat installation documentation) public class HelloServlet extends HttpServlet.
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
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.
JSP Java Server Pages Reference:
MSIS 655 Advanced Business Applications Programming
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
Presentation transcript:

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 to Browser 2. Web Server reads file from disk browser Web Server

Dynamic Content  CGI( Common Gateway Interface )program generates HTML that is returned to Browser 1. Browser sends request to Web Server 5. Web Server sends HTML to Browser User Computer Server 2. Web Server loads CGI program from disk CGI Program 3. Web Server starts CGI program 4. CGI program generates and returns HTML browser Web Server

CGI has issues  performance Web Server must create new process for each request, limits scalability  maintenance presentation and business logic tightly coupled

Alternatives  FastCGI - persistent process  mod_perl - perl interpreter embedded in Apache web server  Server Extensions - Netscape(NSAPI), Microsoft(ISAPI)  Active Server Pages

Java Servlets  replaces CGI  a Java program  runs in Servlet Container or Engine  generates dynamic content(HTML, XML)  now part of J2EE architecture  good performance

Java Servlets Continued...  Advantages generally faster, more efficient than CGI runs as a thread not an OS process Convenience - Java API’s secure - does not run in a shell portable, vendor independent

Java Servlet Diagram  Extends Web Server 1. Browser sends request to Web Server 6. Web Server sends HTML to Browser 2. Web Server sends request to Servlet Engine Servlet 5. Servlet generates and returns HTML browser Web Server Servlet Container DB TopLink 4. Servlet can access database jdbc 3. Servlet Engine runs the servlet

Simple Servlet  public class HelloWorld extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response. setContentType(" text/ html"); PrintWriter out = response. getWriter(); out. println( " " ); out. println( " Hello World ”); out. println( " ”); out. println( " Hello World ”); out. println( " "); }

Servlet Issues  servlet generating HTML results in presentation and business logic tightly coupled with accompanying maintenance issues.

Java Server Pages(JSP)  Built on Servlet technology  simplified way to create pages containing dynamically generated content.  converted into servlet, compiled and run as a normal servlet  timestamp checked at specified interval, regenerated if necessary.

Java Server Pages(JSP) continued...  jsp page contains directives, comments, fixed template data (HTML, XML), jsp expression or tags, scriptlets

Java Server Pages(JSP) continued...  Can be invoked from a browser via URL or from a Servlet  Java code can be in the jsp source keep simple  Java code can be in a Java Bean separates User Interface from Business Logic Used via UseBean tag

Java Server Page Diagram  1. Browser sends request to Web Server 6. Web Server sends HTML to Browser 2. Web Server sends request to Servlet Engine Servlet 6. JSP(Servlet) returns HTML browser Web Server Servlet Container DB TopLink 5. JSP interacts with Java Bean(s) and/or Servlets jdbc 4. Servlet Container runs the JSP (Servlet) jsp JSP Engine Servlet source code Java Compiler JSP (Servlet) Java Bean 3. JSP Engine generates servlet

JSP scripting elements  There is more than one type of JSP “tag,” depending on what you want done with the Java  The expression is evaluated and the result is inserted into the HTML page  The code is inserted into the servlet's service method If code contains declarations, they become local variables of the service method This construction is called a scriptlet  The declarations are inserted into the servlet class, not into a method You can declare instance variables and/or static variables You can declare instance methods and/or static methods 15

Example JSP  Hello! The time is now  Notes: The tag is used, because we are computing a value and inserting it into the HTML The fully qualified name ( java.util.Date ) is used, instead of the short name ( Date ), because we haven’t yet talked about how to do import declarations 16

Variables  You can declare your own variables, as usual  JSP provides several predefined variables request : The HttpServletRequest parameter response : The HttpServletResponse parameter session : The HttpSession associated with the request, or null if there is none out : A JspWriter (like a PrintWriter ) used to send output to the client  Example: Your hostname: 17

Scriptlets  Scriptlets are enclosed in tags Scriptlets are executable code and do not directly affect the HTML Scriptlets may write into the HTML with out.print( value ) and out.println( value ) Example:  Scriptlets are inserted into the servlet exactly as written, and are not compiled until the entire servlet is compiled Example: Have a nice day! Have a lousy day! 18

Declarations  Use for declarations to be added to your servlet class, not to any particular method Caution: Servlets are multithreaded, so nonlocal variables must be handled with extreme care If declared with, variables are local and OK If declared with, variables probably need to be synchronized Data can also safely be put in the request or session objects  Example: Accesses to page since server reboot:  You can use to declare methods as easily as to declare variables 19

Directives  Directives affect the servlet class itself  A directive has the form: or  The most useful directive is page, which lets you import classes and packages Example: 20

The include directive  The include directive inserts another file into the file being parsed The included file is treated as just more JSP, hence it can include static HTML, scripting elements, actions, and directives  Syntax: The URL is treated as relative to the JSP page If the URL begins with a slash, it is treated as relative to the home directory of the Web server  The include directive is especially useful for inserting things like navigation bars 21

Actions  Actions are XML-syntax tags used to control the servlet engine  Inserts the indicated relative URL at execution time (not at compile time, like the include directive does) This is great for rapidly changing data  " /> Jump to the (static) URL or the (dynamically computed) JavaExpression resulting in a URL 22

JSP in XML  JSP can be embedded in XML as well as in HTML  Due to XML’s syntax rules, the tags must be different (but they do the same things)  HTML: XML: expression  HTML: XML: code  HTML: XML: declarations  HTML: XML: 23

Comments  You can put two kinds of comments in JSP: ○ This is an ordinary HTML comment, and forms part of the page that you send to the user ○ Hence, the user can see it by doing View source ○ JSP scriptlets in HTML comments will be executed ○ This kind of comment will be stripped out when the JSP is compiled ○ It’s intended for page developers; the user will never see it 24

Deployment Directories

<% Out.println(“Thank you....”); %>