Java web development Servlet & Java server pages.

Slides:



Advertisements
Similar presentations
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Advertisements

JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
Installing JDK and Tomcat Vijayan Sugumaran Department of DIS Oakland University.
Servlets and a little bit of Web Services Russell Beale.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Part 1: Overview of Web Systems Part 2: Peer-to-Peer Systems Internet Computing Workshop Tom Chothia.
DT228/3 Web Development JSP: Directives and Scripting elements.
Apache Tomcat Server Typical html Request/Response cycle
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,
Website Development with PHP and MySQL Introduction.
Tomcat Configuration A Very, Very, Very Brief Overview.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
CSCI 6962: Server-side Design and Programming History and Background.
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.
SERVLETS.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Intro to Servlets Lec 26. Web-Based Enterprise Applications in Java Figure shows a simplified view of one application and its layers.
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.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Installing and Configuring Tomcat A quick guide to getting things set up on Windows.
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,
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Modern Software Technologies Java™, J2EE™, JSP™, JDBC™ by Radoslav Tr. Ivanov
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
JSP Java Server Pages Softsmith Infotech.
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Java CGI Lecture notes by Theodoros Anagnostopoulos.
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.
Chapter 10 Overview of JSP Technology. Understanding the need for JSP JSP technology enables to mix regular, static HTML with dynamically generated content.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
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 
Introduction to JavaServer Pages. 2 JSP and Servlet Limitations of servlet  It’s inaccessible to non-programmers JSP is a complement to servlet  focuses.
Writing Enterprise Applications with J2EE (Fourth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
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.
Chapter 11 Invoking Java Code with JSP Scripting Elements.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Core basic Java web server technologies. Tools Eclipse IDE for Java EE Developers (Netbeans also works) nloads/packages/eclipse-
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Field Trip #24 Setting Up a Web Server. Apache Apache is one of the most successful open source web servers In 1995 the most popular web server was the.
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
JAVA SERVER PAGES -by Rubeena Memon Deepti Jain Jaya Thakar Jisha Vettuventra.
 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 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.
JSP Java Server Pages. Hello, !
Introduction Servlets and JSP
Java Servlets.
MSIS 655 Advanced Business Applications Programming
J2EE Lecture 1:Servlet and JSP
Presentation transcript:

Java web development Servlet & Java server pages

topics Setting Up a Servlet and JSP Environment *Quick history of web development *CGI *Java servlet *Installing the java 2 Standard Edition 1.4 (J2SE 1.4). *Installing Jakarta Tomcat 5 on Windows Java Servlet Java server pages.

Setting Up a Servlet and JSP Environment Quick history of web development In the beginning, all the web pages is found in the server as HTML files, to open any web page the client send request to the server by sending the web page name or click on the link for this page, when the request reach to the server,this server search about this file and send the response to the client,then the browser show this page at the client. This is called : RequestResponse ClientServer and the request and the response is HTML file. This called : static web pages.

request HTML files search HTML file Response (HTML) Browser view the web page RequestResponse ClientServer

Quick history of web development The number of this static pages become too large and the server can’t keep all these pages. So the users need dynamic pages such as the search pages, the page contents is changed for each client, this contents is come from database which contains new contents for each client request.

Web server Browser Request to execute the program The result (HTML page) database The result (HTML page) Show the page by the browser If the program need database Execute the program The server call the needed program Quick history of web development

CGI The Common Gateway Interface, or CGI, is commonly referred to as one of the first practical technologies for creating dynamic server-side content. with CGI a server passes a client’s request to an external program. This program executes, creates some contents, and sends a response to the client. When first developed, this functionality available to a web developer. Needless to say CGI quickly grew in popularity and become a standard method for creating dynamic web pages.

CGI is not perfect ……. Each request to a CGI resource creates a new process on the server and passes information to the process via standard inputs and environment variables. The CGI life cycle is very taxing on server resources and greatly limits the number of concurrent CGI users a server can support. It takes a noticeable amount of time to start and stop the entire process.

Java servlet In the java world, servlets were designed to solve the problems of CGI. Similar to CGI, servlets allow a request to be processed by a program and let the same program produce a dynamic response. Servlets additionally defined an efficient life cycle that include the possibility of using a single process for managing all requests. This eliminated the multi_process overhead of CGI and allowed for the mail process to share recourses between multiple servlets and multiple requests.

Installing the java 2 Standard Edition 1.4 (J2SE 1.4). J2SE is required to run all java codes, go to You can use jcretor or netbeans to compile and run the programs.

Installing Jakarta Tomcat 5 on Windows Apache Jakarta is freely available for download from To download tomcat go to 55.cgi 55.cgi Why we need the tomcat ? The servlet can’t be execute on any computer, it must execute on a server computer

Installation steps: 1] after download the file, extract the file on the C drive, change the file name to tomcat, the path off the file become : c:\tomcat 2] right click on my computer  properties  advance  Environment Variable 3] in System Variable click on new  the variable name is JAVA_HOME and the value is the path of the JDK in your computer. This path usually is C:\Program Files\Java\jdk1.6.0_22

Installation steps: Copy the file servlet-api.jar found in the path : tomcat\lib to this path : C:\Program Files\Java\jdk1.6.0_22\jre\lib\ext If you don’t copy this file, this common error will appear : javax.servlet package doesn’t exist Go to the path : C:\tomcat\webapps\ROOT\WEB-INF And create a new folder name it classes : C:\tomcat\webapps\ROOT\WEB-INF\classes Now the tomcat is ready, we need to startup the tomcat

Startup the tomcat. Go to : Start-> run -> cmd Use the command cd.. until reach to the folder : c:\tomcat\bin Write the command startup this window will appear:

Open the server from the browser The port number usually is 8080 you can sure by search about the port number from the file : C:\tomcat\conf\sever.xml Search for this statement Open the browser then write : You can use the shutdown command to shutdown the tomcat server.

Open the server from the browser

Execute servlet pages Write the servlet code initially try this code and save it as NewServlet.java : Compile the code and but the NewServlet.class file on the path: C:\tomcat\webapps\ROOT\WEB-INF\classes

Execute servlet pages Write 080/servlet/New Servlet the output is : 080/servlet/New Servlet

Use netbeans to install tomcat and execute the servlet pages :

Servlets… import javax.servlet.servlet; interface define the init() method to match the initilaization phase of servlet life cycle. import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; These two objects represent a client’s request for dynamic resource and the Servlet’s response to the client. import javax.servlet.http.HttpServlet;

doGet and doPost methods

HTML forms and Servlet code example

Java server pages JavaServer Pages (JSP) technology enables you to mix regular, static HTML with dynamically generated content from servlets. You simply write the regular HTML in the normal manner, using familiar Web-page-building tools. You then enclose the code for the dynamic parts in special tags, most of which start with.

Java server pages simple example

JSP JSP A clear important distinction to make about JSP is that coding one is nothing like coding a servlet. There are three different types of scripting elements available for use in jsp: Scriptlets, expression, and declarations.

If you want to do something more complex than insert a simple expression, JSP scriptlets let you insert arbitrary code into the jsp page. Scriptlets have the following form: JSP Scriptlets

The output.

A JSP expression is used to insert values directly into the output. It has the following form: The expression is evaluated, converted to a string, and inserted in the page. This evaluation is performed at run time (when the page is requested) and thus has full access to information about the request. For example, the following shows the date/time that the page was requested: Current time: JSP Expressions JSP Expressions

Deference between expression and scriptles. if you want output to appear in the resultant page, you would use the out variable in the scriptles, as in the following example. <% String queryData = request.getQueryString(); out.println("Attached GET data: " + queryData); %> In this particular instance, you could have accomplished the same effect more easily by using the following JSP expression: Attached GET data:

expression scripltles

The output.

A JSP declaration lets you define methods or fields. A declaration has the following form: Since declarations do not generate any output, they are normally used in conjunction with JSP expressions or scriptlets JSP Declarations

declaration