38
By javawithease

What is Advance Java J2EE

Embed Size (px)

Citation preview

Page 1: What is Advance Java J2EE

Byjavawithease

Page 2: What is Advance Java J2EE
Page 3: What is Advance Java J2EE
Page 4: What is Advance Java J2EE
Page 5: What is Advance Java J2EE

Java EE Containers

Page 6: What is Advance Java J2EE
Page 7: What is Advance Java J2EE

Java Sevlet 3.0 Java Server Pages 2.2 Java Server Faces 2.0 Enterprise JavaBeans 3.1 JavaMail 1.4

Java Sevlet 3.0 Java Server Pages 2.2 Java Server Faces 2.0 Enterprise JavaBeans 3.1 JavaMail 1.4

Page 8: What is Advance Java J2EE

A servlet is a Java programming language class used to extend the capabil i t ies of servers that host applications accessed via a request-response programming model

A servlet is a Java programming language class used to extend the capabil i t ies of servers that host applications accessed via a request-response programming model

Page 9: What is Advance Java J2EE
Page 10: What is Advance Java J2EE
Page 11: What is Advance Java J2EE
Page 12: What is Advance Java J2EE

import java.io.*;import javax.servlet.*;import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {  response.setContentType("text/html");  PrintWriter pw = response.getWriter();  pw.println("<html>");  pw.println("<head><title>Hello World</title></title>");  pw.println("<body>");  pw.println("<h1>Hello World</h1>");  pw.println("</body></html>");}}

import java.io.*;import javax.servlet.*;import javax.servlet.http.*;

public class HelloWorld extends HttpServlet{   public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {  response.setContentType("text/html");  PrintWriter pw = response.getWriter();  pw.println("<html>");  pw.println("<head><title>Hello World</title></title>");  pw.println("<body>");  pw.println("<h1>Hello World</h1>");  pw.println("</body></html>");}}

Page 13: What is Advance Java J2EE

<web-app> <servlet>  <servlet-name>Hello</servlet-name>  <servlet-class>HelloWorld</servlet-class> </servlet>

 <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloWorld</url-pattern> </servlet-mapping>

</web-app>

<web-app> <servlet>  <servlet-name>Hello</servlet-name>  <servlet-class>HelloWorld</servlet-class> </servlet>

 <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloWorld</url-pattern> </servlet-mapping>

</web-app>

Page 14: What is Advance Java J2EE

JavaServer Pages (JSP) is a Java technology that helps Software Developers, serve dynamically generated pages, based on HTML, XML, or other document types

JavaServer Pages (JSP) is a Java technology that helps Software Developers, serve dynamically generated pages, based on HTML, XML, or other document types

Page 15: What is Advance Java J2EE
Page 16: What is Advance Java J2EE

<%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd">

<html>    <head>        <title>JSP Page</title>    </head>    <body>        <h1>            <%                out.println("Hello World");            %>        </h1>    </body></html>

<%@page contentType="text/html" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd">

<html>    <head>        <title>JSP Page</title>    </head>    <body>        <h1>            <%                out.println("Hello World");            %>        </h1>    </body></html>

Page 17: What is Advance Java J2EE

There are five kinds tags that is available in JSP

 Directive Tag Declaration Tag Expression Tag Scriplet

There are five kinds tags that is available in JSP

 Directive Tag Declaration Tag Expression Tag Scriplet

Page 18: What is Advance Java J2EE

JSP directives provide directions and instructions to the container, telling it how to handle certain aspects of JSP processing.A JSP directive affects the overall structure of the servlet class. It usually has the following form:

<%@ directive attr ibute="value" %>

JSP directives provide directions and instructions to the container, telling it how to handle certain aspects of JSP processing.A JSP directive affects the overall structure of the servlet class. It usually has the following form:

<%@ directive attribute="value" %>

Page 19: What is Advance Java J2EE

Types of directive tag:

Page 20: What is Advance Java J2EE

JSP Declarations:A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.

Following is the syntax of JSP Declarations:

<%! declaration; [ declaration; ]+ ... %> You can write XML equivalent of the above syntax as fol lows:

<jsp:declaration> code fragment </jsp:declaration>

Following is the syntax of JSP Declarations:

<%! declaration; [ declaration; ]+ ... %> You can write XML equivalent of the above syntax as follows:

<jsp:declaration> code fragment </jsp:declaration>

Page 21: What is Advance Java J2EE

A JSP expression element contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file.

JSP Expression:

Following is the syntax of JSP Expression:

<%= expression %>

Following is the syntax of JSP Expression:

<%= expression %>

Page 22: What is Advance Java J2EE
Page 23: What is Advance Java J2EE

The Scriptlet:A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.

Following is the syntax of Scriptlet:<% code fragment %>You can write XML equivalent of the above syntax as follows:

<jsp:scriptlet> code fragment </jsp:script let>

Following is the syntax of Scriptlet:<% code fragment %>You can write XML equivalent of the above syntax as follows:

<jsp:scriptlet> code fragment </jsp:scriptlet>

Page 24: What is Advance Java J2EE
Page 25: What is Advance Java J2EE

JSP comment marks text or statements that the JSP container should ignore. A JSP comment is useful when you want to hide or "comment out" part of your JSP page.

JSP Comments:

Following is the syntax of JSP comments:<%-- This is JSP comment --%> Following is the syntax of JSP comments:<%-- This is JSP comment --%>

Page 26: What is Advance Java J2EE
Page 27: What is Advance Java J2EE

<HTML><BODY><FORM METHOD=POST ACTION="SaveName.jsp">What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4><P><INPUT TYPE=SUBMIT></FORM></BODY></HTML>

<HTML><BODY><FORM METHOD=POST ACTION="SaveName.jsp">What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4><P><INPUT TYPE=SUBMIT></FORM></BODY></HTML>

Page 28: What is Advance Java J2EE

public class UserData { String username; String email; int age;

public void setUsername( String value ) { username = value; }

public void setEmail( String value ) { email = value; }

public void setAge( int value ) { age = value; }

public class UserData { String username; String email; int age;

public void setUsername( String value ) { username = value; }

public void setEmail( String value ) { email = value; }

public void setAge( int value ) { age = value; }

Page 29: What is Advance Java J2EE

public String getUsername() { return username; }

public String getEmail() { return email; }

public int getAge() { return age; } }

public String getUsername() { return username; }

public String getEmail() { return email; }

public int getAge() { return age; } }

<jsp:useBean id="user" class="UserData" scope="session"/><jsp:setProperty name="user" property="*"/> <HTML><BODY><A HREF="NextPage.jsp">Continue</A></BODY></HTML>

<jsp:useBean id="user" class="UserData" scope="session"/><jsp:setProperty name="user" property="*"/> <HTML><BODY><A HREF="NextPage.jsp">Continue</A></BODY></HTML>

Page 30: What is Advance Java J2EE

<jsp:useBean id="user" class="UserData" scope="session"/> <HTML><BODY>You entered<BR>Name: <%= user.getUsername() %><BR>Email: <%= user.getEmail() %><BR>Age: <%= user.getAge() %><BR></BODY></HTML>

<jsp:useBean id="user" class="UserData" scope="session"/> <HTML><BODY>You entered<BR>Name: <%= user.getUsername() %><BR>Email: <%= user.getEmail() %><BR>Age: <%= user.getAge() %><BR></BODY></HTML>

Page 31: What is Advance Java J2EE

The Enterprise JavaBeans architecture or EJB for short is an architecture for the development and deployment of component-based robust, highly scalable business applications. These Applications are scalable, transactional, and multi-user secure.

The Enterprise JavaBeans architecture or EJB for short is an architecture for the development and deployment of component-based robust, highly scalable business applications. These Applications are scalable, transactional, and multi-user secure.

Page 32: What is Advance Java J2EE

Benefits of EJBEJB simplifies the development of small and large enterprise applications. The EJB container provides system-level services to enterprise beans, the bean developer can just concentrate on developing logic to solve business problems.

EJB simplifies the development of small and large enterprise applications. The EJB container provides system-level services to enterprise beans, the bean developer can just concentrate on developing logic to solve business problems.

Page 33: What is Advance Java J2EE
Page 34: What is Advance Java J2EE

Session Bean Entity BeanMessage-Driven Bean

Session Bean Entity BeanMessage-Driven Bean

Page 35: What is Advance Java J2EE

Session is one of  the EJBs and it  represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.

A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates. 

Session is one of  the EJBs and it  represents a single client inside the Application Server. Stateless session is easy to develop and its efficient. As compare to entity beans session beans require few server resources.

A session bean is similar to an interactive session and is not shared; it can have only one client, in the same way that an interactive session can have only one user. A session bean is not persistent and it is destroyed once the session terminates. 

Page 36: What is Advance Java J2EE

Stateless Session Beans A stateless session bean does not maintain a conversational state for the client. When a client invokes the method of a stateless bean, the bean's instance variables may contain a state, but only for the duration of the invocation.

Stateful Session BeansThe state of an object consists of the values of its instance variables. In

a stateful session bean, the instance variables represent the state of a unique client-bean session. Because the client interacts ("talks") with its bean, this state is often called the conversational state. 

Stateless Session Beans A stateless session bean does not maintain a conversational state for the client. When a client invokes the method of a stateless bean, the bean's instance variables may contain a state, but only for the duration of the invocation.

Stateful Session BeansThe state of an object consists of the values of its instance variables. In

a stateful session bean, the instance variables represent the state of a unique client-bean session. Because the client interacts ("talks") with its bean, this state is often called the conversational state. 

Session Bean Types

Page 37: What is Advance Java J2EE

Entity beans are persistence java objects, whose state can be saved into the database and later can it can be restored from Data store. Entity bean represents a row of the database table.

Entity beans are persistence java objects, whose state can be saved into the database and later can it can be restored from Data store. Entity bean represents a row of the database table.

Page 38: What is Advance Java J2EE

Message Driven Bean is an enterprise bean that can be used by JEE applications to process the messages asynchronously. Message Driven Bean acts as message consumer and it receives JMS messages.

Message Driven Bean is an enterprise bean that can be used by JEE applications to process the messages asynchronously. Message Driven Bean acts as message consumer and it receives JMS messages.