Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.

Similar presentations


Presentation on theme: "Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development."— Presentation transcript:

1

2 Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development

3 JSP is a java based technology used to simplify the development of dynamic web pages. JSP is used to separate dynamic content of web page from its content with the help of HTML and JSP tags. Current version is 2.1.

4 What the Web Architecture of JSP?

5 JSP Model I Architecture

6 JSP Model II Architecture

7 How Many Stages in JSP life Cycle

8 1.Page Translation stage 2.Page compilation stage 3.Loading & initialization stage 4.Request handling stage 5.Destroying stage

9 Java Enterprise Edition

10 Java Web Development * Note--In this course only JSP & servlets will be discussed

11 There are two kind of structures The structure of the web application in a server The structure of the IDE A web project have three main elements The JSPs files The java classes The Configuration file web.xml Structure of a web project

12 Structure of a web project in the server

13 Anything web-related - Directories - JavaServer Pages (JSP) - HTML - Css files - JavaScript Files - Etc. Java Libraries (.jar) Java classes (.class) Configuration files Root of the project

14 In a Web Application, web components provide the dynamic extension capabilities for a web server. Web components can be Java servlets, JSP pages, or web service endpoints. The interaction between a web client and a web application is explained and illustrated in the next slide figure. The client sends an HTTP request to the web server. A web server that implements Java Servlet and JavaServer Pages technology converts the request into an HTTPServletRequest object. This object is delivered to a web component, which can interact with JavaBeans components or a database to generate dynamic content. The web component can then generate an HTTPServletResponse or it can pass the request to another web component. Eventually a web component generates a HTTPServletResponse object. The web server converts this object to an HTTP response and returns it to the client. Introduction to Web Applications

15

16 Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. Although servlets and JSP pages can be used interchangeably, each has its own strengths. Servlets are best suited for service-oriented applications (web service endpoints are implemented as servlets) and the control functions of a presentation-oriented application, such as dispatching requests and handling nontextual data. JSP pages are more appropriate for generating text-based markup such as HTML, Scalable Vector Graphics (SVG), Wireless Markup Language (WML), and XML. Introduction to Web Applications

17 Servlets versus JSP

18 Life Cycle of a JEE Web Application

19

20 Criteria to develop web applications

21 Develope the first java web application 1.Download the file: jspservlet-00.zip 2.Unzip it 3.Import from Eclipse 4.Run it Exercise 1

22 You should get this result Exercise 1 Results

23 The web.xml file Exercise 1 Analisis HelloWorldServlet com.example.servlets.HelloWorldServlet AnotherServlet com.example.servlets.AnotherServlet Servlet declarations

24 The web.xml file Exercise 1 Analisis... HelloWorldServlet /HelloWorldServlet AnotherServlet /AnotherServlet index.html Servlet mappings

25 Exercise 1 Analisis Servlet classes (other might be here classes too) Other resources might be here

26 JSP life cycle as……….

27 What Are jsp elements an their types????

28 JSP page consist of elements and templates data.These elements are described in different elements type are:- Directives:- JSP directives provides the page resources and their properties. Some are as:- 1. Page directive :-Used to provide page specific properties Eg: Attributes are:- 1.Autoflush=”true/false” 2.Buffer=”in KB” 3.contentType=”info” 4.errorPage=”page url” 5.extends=”classname” 6.import=”package separated by comma” 7.info=”infotext” 8.isELIgnored=”true/false” 9.isErrorPage=”pagenameurl” 10.isThreadSafe=”true/false” 11.language=”java” 12.pageEncoding=”ISO-8859-1” 13.session=”true/false”

29 2. Include Directives:- The include directives tells the container to add the defined resource content inline to the JSP page during the translation time.This tag used to make reusability. Eg :- 3. Taglib Directives:- Taglib tag is used to include external tag library in your web page. Attributes are:- 1.Uri=”url of taglibrary” 2.tagDir=”tag library directory” 3.prefix=”like object for library”

30 1. 2. 3. How many scripting Elements used in JSP?????

31 Now I am Describing Action Elements in JSP ?????????

32 Action elements are certain directives that are given to the container perform certain task during the execution of a JSP page.

33 1. :- The useBean tag is used to create instance for specified java bean for JSP page. Attributes of this tag:- Id => what the object name you want to specifiy for this bean. Scope => whats the scope of bean object page,request,session or application. Class => case sensitive name of bean class beanName => a valid bean name no include the bean classname type => optional attribute java class has been defined. Describing Action Elements in JSP ?????????

34 1. :- this action used to access the defines property to bean object.But it is important to declare bean object using useBean tag. Attributes are:- 1. name :- The name of object where to retrieve object properties. 2. property: - Name of property to get. Eg:- Describing Action Elements in JSP ?????????

35 1. :- this action used to access the defines property to bean object.But it is important to declare bean object using useBean tag. Attributes are:- 1. name :- The name of object where to retrieve object properties. 2. property: - Name of property to get. Eg:- Describing Action Elements in JSP ?????????

36 . :- This action element is used to set the property of bean object specified by usebean tag. Attributes are:- 1.Name :- name of bean which have to specify value 2.Property:- name of property value to be set we can also use * to specify all the property of bean.but in this case you have to specify the name of components as bean property. 3.Param:- The name of the request parameter whose value you want to give to a bean property.this name basically come from web form. 4.Value:- the value to be assign to this property. Eg:- =”propertyname”> Describing Action Elements in JSP ?????????

37 We are creating a login screen with java bean which check the username and password and return the result according to input

38 Index.jsp JSP Page Enter name Enter Password

39 Check.jsp Page:- JSP Page Your Name: Your Password is:

40 Bean.login bean:- /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package beans; /** * * @author BARDHAN */ public class login { private String name; private String password; private boolean result; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public boolean getResult() { if(this.name.equals("sanju")&&password.e quals("123")) { result=true; } else { result=false; } return result; } }

41 4.. :- This action element is used to pass the parameter to other action elements. For example Describing Action Elements in JSP ?????????

42 5. :- This action element is used to include any jsp file in your web page. 6. :- Used to forward request control to next page.For example 7. :- work like expression script 8. :- work like as script element 9. :-work as declaration element Describing Action Elements in JSP ?????????

43 JSP Implicit objects are described as follows 1.Application :- Used as Servlet Context object in servlets 2.Config:- Used as ServletConfig object in servlets 3.Out :- JSPWriter object to print any thing on jsp page 4.Page:- work like as Object class object 5.pageContext:- PageConext for JSP page 6.request: work like as ServletRequest object 7.response:- work like as ServletResponse Object in Servlets 8.session :- like as httpSession. Describing the JSP Implicit Objects…………………….


Download ppt "Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development."

Similar presentations


Ads by Google