SlideShare a Scribd company logo
1
By Shaharyar Khan
shaharyar.khan555@gmail.com
 Before going to understand that what is J2EE, first We should
look into that what is Enterprise level
 We can say that
“When our application is composed of n-tier(mostly 3-
tier) , this will be Enterprise application”
2
So
“Implementation Provided By JAVA for the handling
enterprise level can be called J2EE”
shaharyar.khan555@gmail.com
 The J2EE platform provides an API and runtime
environment for developing and running enterprise
software, including
 network Services
 web services
 other large-scale multi-tiered services &
network applications
 As well as scalable, reliable, and secure
network applications
3
 Java EE extends the Java Platform, Standard Edition (Java
SE), providing an API for object-relational mapping,
distributed and multi-tier architectures, and web services
shaharyar.khan555@gmail.com
 Software for Java EE is primarily developed in the Java
programming language and uses XML for configuration.
 The platform was known as Java 2 Platform, Enterprise Edition
or J2EE until the name was changed to Java EE in version 5.
The current version is called Java EE 6.
4shaharyar.khan555@gmail.com
5shaharyar.khan555@gmail.com
 The J2EE platform uses a multitier distributed application model. This
means application logic is divided into components according to
function, and the various application components that make up a
J2EE application are installed on different machines depending on
which tier in the multitier JEE environment the application
component belongs.
6
shaharyar.khan555@gmail.com
 JEE applications are made up of components
Application clients and applets are client
components.
Java Servlet and JavaServer Pages (JSP) technology
components are web components.
Enterprise JavaBeans (EJB) components (enterprise
beans) are business components.
7shaharyar.khan555@gmail.com
 A J2EE application can be web-based or non-web-based. An
application client executes on the client machine for a non-
web-based J2EE application, and a web browser downloads
web pages and applets to the client machine for a web-based
J2EE application.
8
shaharyar.khan555@gmail.com
 J2EE web components can be either JSP pages or servlets
 Servlets are Java programming language classes that
dynamically process requests and construct responses
 JSP pages are text-based documents that contain static
content and snippets of Java programming language code to
generate dynamic content
9
shaharyar.khan555@gmail.com
10
 Business code, which is logic that solves or meets the needs
of a particular business domain such as banking, retail, or
finance, is handled by enterprise beans running in the
business tier
 There are three kinds of enterprise beans:
 session beans
 entity beans
 message-driven beans
shaharyar.khan555@gmail.com
 Component are installed in their containers during
deployment and are the interface between a component and
the low-level platform-specific functionality that supports
the component
 Before a web, enterprise bean, or application client
component can be executed, it must be assembled into a J2EE
application and deployed into its container.
11shaharyar.khan555@gmail.com
 An Enterprise JavaBeans (EJB) container manages the execution of all
enterprise beans for one J2EE application. Enterprise beans and their
container run on the J2EE server.
 A web container manages the execution of all JSP page and servlet
components for one J2EE application. Web components and their
container run on the J2EE server.
 An application client container manages the execution of all application
client components for one J2EE application. Application clients and their
container run on the client machine.
 An applet container is the web browser and Java Plug-in combination
running on the client machine.They are also part of client machine
12shaharyar.khan555@gmail.com
13shaharyar.khan555@gmail.com
14shaharyar.khan555@gmail.com
15shaharyar.khan555@gmail.com
 J2EE ( Java 2 -Enterprise Edition) is a basket of  12 inter-
related technologies , which can be grouped as follows for
convenience.:
16
Group-1  (Web-Server  &  support Technologies )
=====================================
  1) JDBC   (  Java Database Connectivity)
  2) Servlets
  3) JSP   (Java Server Pages)
  4) Java Mail
_____________________________________________
Group-2   ( Distributed-Objects Technologies)
=====================================
  5) RMI  (Remote Method Invocation)
  6) Corba-IDL   ( Corba-using Java  with OMG-IDL)
  7) RMI-IIOP   (Corba in Java without OMG-IDL)
  8) EJB   (Enterprise Java Beans)
________________________________________________
shaharyar.khan555@gmail.com
Group-3  (  Supporting & Advanced Enterprise technologies)
=============================================
  9) JNDI   ( Java Naming & Directory Interfaces)
   10) JMS   ( Java Messaging Service)
   11) JAVA-XML  ( such as JAXP, JAXM, JAXR, JAX-RPC, JAXB, and XML-WEB
SERVICE)
   12) Connectors ( for ERP and Legacy systems).
Now we will cover some important technologies from these.
17shaharyar.khan555@gmail.com
 We all know about network sockets very well , their purpose
and usage
 Let us see the difference in implementation of sockets among
the c# and JAVA
 Steps are same
 Open a socket.
 Open an input stream and output stream to the socket.
 Read from and write to the stream according to the server's
protocol.
 Close the streams.
 Close the socket.
18shaharyar.khan555@gmail.com
19
 In c# (client Socket)
 System.Net.Sockets.TcpClient clientSocket = new
System.Net.Sockets.TcpClient();
And after then we will connect to specific server
 clientSocket.Connect("127.0.0.1", 8888);
 In JAVA(client Socket)
 Socket client = new Socket(("127.0.0.1", 8888);
Only in this line we can create socket as well as connect to the server
shaharyar.khan555@gmail.com
20
 In c # (Server Socket)
 TcpListener serverSocket = new TcpListener(8888);
And after then we will connect to specific server
 serverSocket.Start();
 In JAVA(Server Socket)
 serverSocket = new ServerSocket(8888);
This will acccept the connection from the client
 Socket server = serverSocket.accept();
shaharyar.khan555@gmail.com
21
import java.net.*;
import java.io.*;
public class GreetingClient {
public static void main(String [] args) {
String serverName = args[0];
int port = Integer.parseInt(args[1]);
try {
System.out.println("Connecting to " + serverName + " on port
" + port);
Socket client = new Socket(serverName, port);
System.out.println("Just connected to " +
client.getRemoteSocketAddress());
OutputStream outToServer = client.getOutputStream();
DataOutputStream out = new DataOutputStream(outToServer);
out.writeUTF("Hello from " + client.getLocalSocketAddress());
InputStream inFromServer = client.getInputStream();
DataInputStream in = new DataInputStream(inFromServer);
System.out.println("Server says " + in.readUTF());
client.close();
}catch(IOException e) {
e.printStackTrace();
}
}
}
shaharyar.khan555@gmail.com
22
import java.net.*;
import java.io.*;
public class GreetingServer extends Thread {
private ServerSocket serverSocket;
public GreetingServer(int port) throws IOException {
serverSocket = new ServerSocket(port);
serverSocket.setSoTimeout(10000); }
public void run() {
while(true) {
try{
System.out.println("Waiting for client on port " +
serverSocket.getLocalPort() + "...");
Socket server = serverSocket.accept();
System.out.println("Just connected to “
+server.getRemoteSocketAddress());
DataInputStream in = new
DataInputStream(server.getInputStream());
System.out.println(in.readUTF());
DataOutputStream out = new
DataOutputStream(server.getOutputStream());
out.writeUTF("Thank you for connecting to " +
server.getLocalSocketAddress() + "nGoodbye!");
server.close();
}catch(SocketTimeoutException s) {
System.out.println("Socket timed out!");
break;
}catch(IOException e) {
e.printStackTrace(); break;
}
}
}
shaharyar.khan555@gmail.com
public static void main(String [] args) {
int port = Integer.parseInt(args[0]);
try {
Thread t = new GreetingServer(port);
t.start();
}catch(IOException e) {
e.printStackTrace();
}
}
}
23shaharyar.khan555@gmail.com
24
Java Database Connectivity or JDBC for short is set of Java
API's that enables the developers to create platform and
database independent applications in java.
Connect to any database through java is very simple and
requires only few steps
Import the packages . Requires that you include the packages
containing the JDBC classes needed for
database programming. Most often, using
import java.sql.* will suffice.
Register the JDBC driver . Requires that you initialize a driver so
you can open a communications
channel with the database.
Open a connection . Requires using the
DriverManager.getConnection() method to
create a Connection object, which represents a
physical connection with the database.
shaharyar.khan555@gmail.com
25
Execute a query . Requires using an object of type Statement for
building and submitting an SQL statement to the database.
Extract data from result set . Requires that you use the
appropriate ResultSet.getAnyThing() method to retrieve the data
from the result set.
Clean up the environment . Requires explicitly closing all
database resources versus relying on the JVM's garbage
collection.
shaharyar.khan555@gmail.com
26
import java.sql.*;
public class InsertValues{
 public static void main(String[] args) {
  System.out.println("Inserting values in Mysql database table!");
  Connection con = null;
  String url = "jdbc:mysql://localhost:3306/";
  String db = “deltaDB";
  String driver = "com.mysql.jdbc.Driver";
  try{
  Class.forName(driver);
  con = DriverManager.getConnection(url+db,"root","root");
  try{
  Statement st = con.createStatement();
  int val = st.executeUpdate("INSERT employee
VALUES("+13+","+"‘shaharyar'"+")");
  System.out.println("1 row affected");
  }catch (SQLException s){
  System.out.println("SQL statement is not
executed!");
  }
  }catch (Exception e){
  e.printStackTrace();
  }
  }
}
shaharyar.khan555@gmail.com
27
Oracle  oracle.jdbc.driver.OracleDriver
MSSQL  com.microsoft.sqlserver.jdbc.SQLServerDriver
Postgres  org.postgresql.Driver
MS access  sun.jdbc.odbc.JdbcOdbcDriver
DB2  COM.ibm.db2.jdbc.app.DB2Driver
shaharyar.khan555@gmail.com
28shaharyar.khan555@gmail.com
29shaharyar.khan555@gmail.com
30shaharyar.khan555@gmail.com
31
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.servlet.*;
import javax.servlet.http.*;
public class TestServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
res.setContentType("text/html");
PrintWriter out = res.getWriter(); /* Display some response to
the user */
out.println("<html><head>");
out.println("<title>TestServlet</title>");
out.println("t<style>body { font-family:
'Lucida Grande', " + "'Lucida Sans Unicode';font-
size: 13px; }</style>");
out.println("</head>");
out.println("<body>"); out.println("<p>Current Date/Time: " +
new Date().toString() + "</p>");
out.println("</body></html>"); out.close();
}
} shaharyar.khan555@gmail.com
32
Object Class
application javax.servlet.ServletContext
config javax.servlet.ServletConfig
exception java.lang.Throwable
out javax.servlet.jsp.JspWriter
page java.lang.Object
PageContext javax.servlet.jsp.PageContext
request javax.servlet.ServletRequest
response javax.servlet.ServletResponse
session javax.servlet.http.HttpSession
shaharyar.khan555@gmail.com
33
Sessions are very easy to build and track in java servlets.
We can create a session like this
And easily we can get its value on anyother servlet
param = (Integer) session.getAttribute(“name");
shaharyar.khan555@gmail.com
34
Cookies are also very simple to build and track in java servlets like sessions.
We can create a cookies like this
And easily we can get its value on anyother servlet
String cookieName = "username";
Cookie cookies [] = request.getCookies ();
Cookie myCookie = null;
if (cookies != null)
{
for (int i = 0; i < cookies.length; i++) 
{
if (cookies [i].getName().equals (cookieName))
{
myCookie = cookies[i];
break;
}
}
}
shaharyar.khan555@gmail.com
35
 With servlets, it is easy to
Read form data
Read HTTP request headers
Set HTTP status codes and response headers
Use cookies and session tracking
Share data among servlets
Remember data between requests
Get fun, high-paying jobs
But, it sure is a pain to
Use those println statements to generate HTML
Maintain that HTML
shaharyar.khan555@gmail.com
36
 Functionality and life cycle of JSP and servlet are exactly
same.
 A JSP page , after loading first convert into a servlet.
 The only benefit ,which is surly very much effective is that a
programmer can be get rid of hectic coding of servlets
 A designer can eaisly design in JSP without knowledge of
JAVA
shaharyar.khan555@gmail.com
37
 All code is in Tags as JSP is a scripting language.
 Tags of JSPs are given below
Directives
In the directives we can import packages, define error handling
pages or the session information of the JSP page  
Declarations
This tag is used for defining the functions and variables to be used
in the JSP 
Scriplets
In this tag we can insert any amount of valid java code and these
codes are placed in _jspService method by the JSP engine
Expressions
We can use this tag to output any data on the generated page.
These data are automatically converted to string and printed on
the output stream.
shaharyar.khan555@gmail.com
38
 Action Tag:
Action tag is used to transfer the control between pages and
is also used to enable the use of server side JavaBeans.
Instead of using Java code, the programmer uses special JSP
action tags to either link to a Java Bean set its properties, or
get its properties.
shaharyar.khan555@gmail.com
39
 Syntax of JSP directives is:
<%@directive attribute="value" %>
Where directive may be:
 page: page is used to provide the information about it.
Example: <%@page import="java.util.*, java.lang.*" %> 
 
 include: include is used to include a file in the JSP page.
Example: <%@ include file="/header.jsp" %> 
  
 taglib: taglib is used to use the custom tags in the JSP pages (custom tags
allows us to defined our own tags).
Example: <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %> 
 
shaharyar.khan555@gmail.com
40shaharyar.khan555@gmail.com
41shaharyar.khan555@gmail.com
42
 Syntax of JSP Declaratives are:  
<%!
  //java codes
   %>
JSP Declaratives begins with <%! and ends %> with .We can
embed any amount of java code in the JSP Declaratives. Variables
and functions defined in the declaratives are class level and can be
used anywhere in the JSP page.
 
shaharyar.khan555@gmail.com
43shaharyar.khan555@gmail.com
44
Syntax of JSP Expressions are:
 
<%="Any thing"   %>
JSP Expressions start with 
Syntax of JSP Scriptles are with <%= and ends with  %>. Between
these this you can put anything and that will converted to the
String and that will be displayed.
Example:
  <%="Hello World!" %>
Above code will display 'Hello World!'.
shaharyar.khan555@gmail.com
45
These are the most commonly used action tags are :
include
forward
param
useBean
setProperty
getProperty
Let discuss some tags among these ….
shaharyar.khan555@gmail.com
46
Include directive:
<%@ include file= "index.jsp" %>
Include Action
<jsp: include page= "index.jsp
Forward Tag:
<jsp:forward page= "Header.html"/>
Pram Tag:
<jsp:param name="result" value="<%=result%>"/>
shaharyar.khan555@gmail.com
47
Everywhere, in any programming language , it is
recommended that apply best programming practices.
In JAVA, a java programmer always prefer to apply
design patterns while coding.
Design Patterns are specific type of coding styles that
should use in specific scenarios.
Let Discuss some basic Design Patterns that we should
use
shaharyar.khan555@gmail.com
48
The Singleton design pattern ensures that only one
instance of a class is created.
it provides a global point of access to the object and allow
multiple instances in the future without affecting a
singleton class's clients
To ensure that only one instance of a class is created we
make SingletonPattern’s instance as static
Let Discuss some basic Design Patterns that we should
use
shaharyar.khan555@gmail.com
49
class SingletonClass{
private static SingletonClass instance;
private SingletonClass(){
}
public static synchronized SingletonClass getInstance(){
if(instance == null)
instance = new SingletonClass();
return instance;
}
}
shaharyar.khan555@gmail.com
50
class MyClass{
public static void main(String[] args) {
SingletonClass sp = SingletonClass.getInstance();
System.out.println("first Instance: "+sp.toString());
SingletonClass sp1 = SingletonClass.getInstance();
System.out.println("2nd Instance: "+sp1.toString());
}
}
You will see in output that both references will be
same
shaharyar.khan555@gmail.com
51
 Factory pattern comes into creational design pattern category
 the main objective of the creational pattern is to instantiate an object
and in Factory Pattern an interface is responsible for creating the
object but the sub classes decides which class to instantiate
 The Factory patterns can be used in following cases:
1. When a class does not know which class of objects it must
create.
2. A class specifies its sub-classes to specify which objects to
create.
3. In programmer’s language (very raw form), you can use
factory pattern where you have to create an object of any one of
sub-classes depending on the data provided.
shaharyar.khan555@gmail.com
52
public class Person {
// name string
public String name;
// gender : M or F
private String gender;
public String
getName() {
return name;
}
public String
getGender() {
return gender;
}
}// End of class
shaharyar.khan555@gmail.com
53
public class Male extends Person {
public Male(String fullName)
{
System.out.println("Hello Mr.
"+fullName);
}
}// End of class
public class Female extends Person {
public Female(String fullNname) {
System.out.println("Hello Ms.
"+fullNname);
}
}// End of class
shaharyar.khan555@gmail.com
54
public class SalutationFactory {
public static void main(String args[]) {
SalutationFactory factory = new
SalutationFactory();
Person p =
factory.getPerson(“Shaharyar”,”M”);
}
public Person getPerson(String name, String
gender) {
if (gender.equals("M"))
return new Male(name);
else if(gender.equals("F"))
return new Female(name);
else
return null;
}
}// End of class
shaharyar.khan555@gmail.com
55
To keep things simple you can understand it like, you have a
set of ‘related’ factory method design pattern. Then you will
put all those set of simple factories inside a factory pattern
In abstract factory , We create a interface instead of class and
then use it for the creation of objects
Simply , When we have a lot of place to apply factory method
then we combine all of them in a interface and use them
according to our needs
shaharyar.khan555@gmail.com
56
Facade as the name suggests means the face of the building.
The people walking past the road can only see this glass face
of the building. They do not know anything about it, the
wiring, the pipes and other complexities. The face hides all the
complexities of the building and displays a friendly face.
hides the complexities of the system and provides an interface
to the client from where the client can access the system
In Java, the interface JDBC can be called a facade. We as users
or clients create connection using the “java.sql.Connection”
interface, the implementation of which we are not concerned
about. The implementation is left to the vendor of driver.
shaharyar.khan555@gmail.com
57

More Related Content

What's hot

What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
Michel Schudel
 
Top 50 Performance Testing Interview Questions | Edureka
Top 50 Performance Testing Interview Questions | EdurekaTop 50 Performance Testing Interview Questions | Edureka
Top 50 Performance Testing Interview Questions | Edureka
Edureka!
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
Fahad Golra
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login application
Somkiat Puisungnoen
 
Core java introduction
Core java introduction Core java introduction
Core java introduction
Som Prakash Rai
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overview
odedns
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
Mehul Jariwala
 
Nouveautés Java 9-10-11
Nouveautés Java 9-10-11Nouveautés Java 9-10-11
Nouveautés Java 9-10-11
Mahamadou TOURE, Ph.D.
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium
Edureka!
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
Tomáš Drenčák
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overview
Rudy De Busscher
 
JavaFX
JavaFXJavaFX
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
Bojan Golubović
 
Curso Java Básico Aula 01: Introdução e Dicas para quem está Começando
Curso Java Básico Aula 01: Introdução e Dicas para quem está ComeçandoCurso Java Básico Aula 01: Introdução e Dicas para quem está Começando
Curso Java Básico Aula 01: Introdução e Dicas para quem está Começando
Loiane Groner
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
Ranjan Kumar
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
Ippon
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 

What's hot (20)

Jpa
JpaJpa
Jpa
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Top 50 Performance Testing Interview Questions | Edureka
Top 50 Performance Testing Interview Questions | EdurekaTop 50 Performance Testing Interview Questions | Edureka
Top 50 Performance Testing Interview Questions | Edureka
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login application
 
Core java introduction
Core java introduction Core java introduction
Core java introduction
 
Mockito
MockitoMockito
Mockito
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overview
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Nouveautés Java 9-10-11
Nouveautés Java 9-10-11Nouveautés Java 9-10-11
Nouveautés Java 9-10-11
 
Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium Data driven Automation Framework with Selenium
Data driven Automation Framework with Selenium
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overview
 
JavaFX
JavaFXJavaFX
JavaFX
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
Curso Java Básico Aula 01: Introdução e Dicas para quem está Começando
Curso Java Básico Aula 01: Introdução e Dicas para quem está ComeçandoCurso Java Básico Aula 01: Introdução e Dicas para quem está Começando
Curso Java Básico Aula 01: Introdução e Dicas para quem está Começando
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 

Similar to J2ee

AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
 
EJ NOV-18 (Sol) (E-next.in).pdf
EJ NOV-18 (Sol) (E-next.in).pdfEJ NOV-18 (Sol) (E-next.in).pdf
EJ NOV-18 (Sol) (E-next.in).pdf
SPAMVEDANT
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDESbputhal
 
Lec6 ecom fall16
Lec6 ecom fall16Lec6 ecom fall16
Lec6 ecom fall16
Zainab Khallouf
 
Project Presentation on Advance Java
Project Presentation on Advance JavaProject Presentation on Advance Java
Project Presentation on Advance JavaVikas Goyal
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
ADEEBANADEEM
 
Java EE 7 introduction
Java EE 7  introductionJava EE 7  introduction
Java EE 7 introduction
Moumie Soulemane
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
Moumie Soulemane
 
Lec2 ecom fall16
Lec2 ecom fall16Lec2 ecom fall16
Lec2 ecom fall16
Zainab Khallouf
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
Sandeep Rawat
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - Introduction
Joel Briza
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
Divyam Pateriya
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
s4al_com
 
Weblogic 12c Graphical Mode installation steps in Windows
Weblogic 12c Graphical Mode installation steps in Windows Weblogic 12c Graphical Mode installation steps in Windows
Weblogic 12c Graphical Mode installation steps in Windows
webservicesm
 
12c weblogic installation steps for Windows
12c weblogic installation steps for Windows12c weblogic installation steps for Windows
12c weblogic installation steps for Windows
Cognizant
 

Similar to J2ee (20)

Jdbc
JdbcJdbc
Jdbc
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
EJ NOV-18 (Sol) (E-next.in).pdf
EJ NOV-18 (Sol) (E-next.in).pdfEJ NOV-18 (Sol) (E-next.in).pdf
EJ NOV-18 (Sol) (E-next.in).pdf
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
J2EE Architecture Explained
J2EE  Architecture ExplainedJ2EE  Architecture Explained
J2EE Architecture Explained
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDES
 
Lec6 ecom fall16
Lec6 ecom fall16Lec6 ecom fall16
Lec6 ecom fall16
 
Project Presentation on Advance Java
Project Presentation on Advance JavaProject Presentation on Advance Java
Project Presentation on Advance Java
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
 
Java EE 7 introduction
Java EE 7  introductionJava EE 7  introduction
Java EE 7 introduction
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
 
Lec2 ecom fall16
Lec2 ecom fall16Lec2 ecom fall16
Lec2 ecom fall16
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - Introduction
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Weblogic 12c Graphical Mode installation steps in Windows
Weblogic 12c Graphical Mode installation steps in Windows Weblogic 12c Graphical Mode installation steps in Windows
Weblogic 12c Graphical Mode installation steps in Windows
 
12c weblogic installation steps for Windows
12c weblogic installation steps for Windows12c weblogic installation steps for Windows
12c weblogic installation steps for Windows
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 

Recently uploaded

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

J2ee

  • 2.  Before going to understand that what is J2EE, first We should look into that what is Enterprise level  We can say that “When our application is composed of n-tier(mostly 3- tier) , this will be Enterprise application” 2 So “Implementation Provided By JAVA for the handling enterprise level can be called J2EE” shaharyar.khan555@gmail.com
  • 3.  The J2EE platform provides an API and runtime environment for developing and running enterprise software, including  network Services  web services  other large-scale multi-tiered services & network applications  As well as scalable, reliable, and secure network applications 3  Java EE extends the Java Platform, Standard Edition (Java SE), providing an API for object-relational mapping, distributed and multi-tier architectures, and web services shaharyar.khan555@gmail.com
  • 4.  Software for Java EE is primarily developed in the Java programming language and uses XML for configuration.  The platform was known as Java 2 Platform, Enterprise Edition or J2EE until the name was changed to Java EE in version 5. The current version is called Java EE 6. 4shaharyar.khan555@gmail.com
  • 6.  The J2EE platform uses a multitier distributed application model. This means application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on which tier in the multitier JEE environment the application component belongs. 6 shaharyar.khan555@gmail.com
  • 7.  JEE applications are made up of components Application clients and applets are client components. Java Servlet and JavaServer Pages (JSP) technology components are web components. Enterprise JavaBeans (EJB) components (enterprise beans) are business components. 7shaharyar.khan555@gmail.com
  • 8.  A J2EE application can be web-based or non-web-based. An application client executes on the client machine for a non- web-based J2EE application, and a web browser downloads web pages and applets to the client machine for a web-based J2EE application. 8 shaharyar.khan555@gmail.com
  • 9.  J2EE web components can be either JSP pages or servlets  Servlets are Java programming language classes that dynamically process requests and construct responses  JSP pages are text-based documents that contain static content and snippets of Java programming language code to generate dynamic content 9 shaharyar.khan555@gmail.com
  • 10. 10  Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier  There are three kinds of enterprise beans:  session beans  entity beans  message-driven beans shaharyar.khan555@gmail.com
  • 11.  Component are installed in their containers during deployment and are the interface between a component and the low-level platform-specific functionality that supports the component  Before a web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container. 11shaharyar.khan555@gmail.com
  • 12.  An Enterprise JavaBeans (EJB) container manages the execution of all enterprise beans for one J2EE application. Enterprise beans and their container run on the J2EE server.  A web container manages the execution of all JSP page and servlet components for one J2EE application. Web components and their container run on the J2EE server.  An application client container manages the execution of all application client components for one J2EE application. Application clients and their container run on the client machine.  An applet container is the web browser and Java Plug-in combination running on the client machine.They are also part of client machine 12shaharyar.khan555@gmail.com
  • 16.  J2EE ( Java 2 -Enterprise Edition) is a basket of  12 inter- related technologies , which can be grouped as follows for convenience.: 16 Group-1  (Web-Server  &  support Technologies ) =====================================   1) JDBC   (  Java Database Connectivity)   2) Servlets   3) JSP   (Java Server Pages)   4) Java Mail _____________________________________________ Group-2   ( Distributed-Objects Technologies) =====================================   5) RMI  (Remote Method Invocation)   6) Corba-IDL   ( Corba-using Java  with OMG-IDL)   7) RMI-IIOP   (Corba in Java without OMG-IDL)   8) EJB   (Enterprise Java Beans) ________________________________________________ shaharyar.khan555@gmail.com
  • 17. Group-3  (  Supporting & Advanced Enterprise technologies) =============================================   9) JNDI   ( Java Naming & Directory Interfaces)    10) JMS   ( Java Messaging Service)    11) JAVA-XML  ( such as JAXP, JAXM, JAXR, JAX-RPC, JAXB, and XML-WEB SERVICE)    12) Connectors ( for ERP and Legacy systems). Now we will cover some important technologies from these. 17shaharyar.khan555@gmail.com
  • 18.  We all know about network sockets very well , their purpose and usage  Let us see the difference in implementation of sockets among the c# and JAVA  Steps are same  Open a socket.  Open an input stream and output stream to the socket.  Read from and write to the stream according to the server's protocol.  Close the streams.  Close the socket. 18shaharyar.khan555@gmail.com
  • 19. 19  In c# (client Socket)  System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient(); And after then we will connect to specific server  clientSocket.Connect("127.0.0.1", 8888);  In JAVA(client Socket)  Socket client = new Socket(("127.0.0.1", 8888); Only in this line we can create socket as well as connect to the server shaharyar.khan555@gmail.com
  • 20. 20  In c # (Server Socket)  TcpListener serverSocket = new TcpListener(8888); And after then we will connect to specific server  serverSocket.Start();  In JAVA(Server Socket)  serverSocket = new ServerSocket(8888); This will acccept the connection from the client  Socket server = serverSocket.accept(); shaharyar.khan555@gmail.com
  • 21. 21 import java.net.*; import java.io.*; public class GreetingClient { public static void main(String [] args) { String serverName = args[0]; int port = Integer.parseInt(args[1]); try { System.out.println("Connecting to " + serverName + " on port " + port); Socket client = new Socket(serverName, port); System.out.println("Just connected to " + client.getRemoteSocketAddress()); OutputStream outToServer = client.getOutputStream(); DataOutputStream out = new DataOutputStream(outToServer); out.writeUTF("Hello from " + client.getLocalSocketAddress()); InputStream inFromServer = client.getInputStream(); DataInputStream in = new DataInputStream(inFromServer); System.out.println("Server says " + in.readUTF()); client.close(); }catch(IOException e) { e.printStackTrace(); } } } shaharyar.khan555@gmail.com
  • 22. 22 import java.net.*; import java.io.*; public class GreetingServer extends Thread { private ServerSocket serverSocket; public GreetingServer(int port) throws IOException { serverSocket = new ServerSocket(port); serverSocket.setSoTimeout(10000); } public void run() { while(true) { try{ System.out.println("Waiting for client on port " + serverSocket.getLocalPort() + "..."); Socket server = serverSocket.accept(); System.out.println("Just connected to “ +server.getRemoteSocketAddress()); DataInputStream in = new DataInputStream(server.getInputStream()); System.out.println(in.readUTF()); DataOutputStream out = new DataOutputStream(server.getOutputStream()); out.writeUTF("Thank you for connecting to " + server.getLocalSocketAddress() + "nGoodbye!"); server.close(); }catch(SocketTimeoutException s) { System.out.println("Socket timed out!"); break; }catch(IOException e) { e.printStackTrace(); break; } } } shaharyar.khan555@gmail.com
  • 23. public static void main(String [] args) { int port = Integer.parseInt(args[0]); try { Thread t = new GreetingServer(port); t.start(); }catch(IOException e) { e.printStackTrace(); } } } 23shaharyar.khan555@gmail.com
  • 24. 24 Java Database Connectivity or JDBC for short is set of Java API's that enables the developers to create platform and database independent applications in java. Connect to any database through java is very simple and requires only few steps Import the packages . Requires that you include the packages containing the JDBC classes needed for database programming. Most often, using import java.sql.* will suffice. Register the JDBC driver . Requires that you initialize a driver so you can open a communications channel with the database. Open a connection . Requires using the DriverManager.getConnection() method to create a Connection object, which represents a physical connection with the database. shaharyar.khan555@gmail.com
  • 25. 25 Execute a query . Requires using an object of type Statement for building and submitting an SQL statement to the database. Extract data from result set . Requires that you use the appropriate ResultSet.getAnyThing() method to retrieve the data from the result set. Clean up the environment . Requires explicitly closing all database resources versus relying on the JVM's garbage collection. shaharyar.khan555@gmail.com
  • 26. 26 import java.sql.*; public class InsertValues{  public static void main(String[] args) {   System.out.println("Inserting values in Mysql database table!");   Connection con = null;   String url = "jdbc:mysql://localhost:3306/";   String db = “deltaDB";   String driver = "com.mysql.jdbc.Driver";   try{   Class.forName(driver);   con = DriverManager.getConnection(url+db,"root","root");   try{   Statement st = con.createStatement();   int val = st.executeUpdate("INSERT employee VALUES("+13+","+"‘shaharyar'"+")");   System.out.println("1 row affected");   }catch (SQLException s){   System.out.println("SQL statement is not executed!");   }   }catch (Exception e){   e.printStackTrace();   }   } } shaharyar.khan555@gmail.com
  • 27. 27 Oracle  oracle.jdbc.driver.OracleDriver MSSQL  com.microsoft.sqlserver.jdbc.SQLServerDriver Postgres  org.postgresql.Driver MS access  sun.jdbc.odbc.JdbcOdbcDriver DB2  COM.ibm.db2.jdbc.app.DB2Driver shaharyar.khan555@gmail.com
  • 31. 31 import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import javax.servlet.*; import javax.servlet.http.*; public class TestServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); /* Display some response to the user */ out.println("<html><head>"); out.println("<title>TestServlet</title>"); out.println("t<style>body { font-family: 'Lucida Grande', " + "'Lucida Sans Unicode';font- size: 13px; }</style>"); out.println("</head>"); out.println("<body>"); out.println("<p>Current Date/Time: " + new Date().toString() + "</p>"); out.println("</body></html>"); out.close(); } } shaharyar.khan555@gmail.com
  • 32. 32 Object Class application javax.servlet.ServletContext config javax.servlet.ServletConfig exception java.lang.Throwable out javax.servlet.jsp.JspWriter page java.lang.Object PageContext javax.servlet.jsp.PageContext request javax.servlet.ServletRequest response javax.servlet.ServletResponse session javax.servlet.http.HttpSession shaharyar.khan555@gmail.com
  • 33. 33 Sessions are very easy to build and track in java servlets. We can create a session like this And easily we can get its value on anyother servlet param = (Integer) session.getAttribute(“name"); shaharyar.khan555@gmail.com
  • 34. 34 Cookies are also very simple to build and track in java servlets like sessions. We can create a cookies like this And easily we can get its value on anyother servlet String cookieName = "username"; Cookie cookies [] = request.getCookies (); Cookie myCookie = null; if (cookies != null) { for (int i = 0; i < cookies.length; i++)  { if (cookies [i].getName().equals (cookieName)) { myCookie = cookies[i]; break; } } } shaharyar.khan555@gmail.com
  • 35. 35  With servlets, it is easy to Read form data Read HTTP request headers Set HTTP status codes and response headers Use cookies and session tracking Share data among servlets Remember data between requests Get fun, high-paying jobs But, it sure is a pain to Use those println statements to generate HTML Maintain that HTML shaharyar.khan555@gmail.com
  • 36. 36  Functionality and life cycle of JSP and servlet are exactly same.  A JSP page , after loading first convert into a servlet.  The only benefit ,which is surly very much effective is that a programmer can be get rid of hectic coding of servlets  A designer can eaisly design in JSP without knowledge of JAVA shaharyar.khan555@gmail.com
  • 37. 37  All code is in Tags as JSP is a scripting language.  Tags of JSPs are given below Directives In the directives we can import packages, define error handling pages or the session information of the JSP page   Declarations This tag is used for defining the functions and variables to be used in the JSP  Scriplets In this tag we can insert any amount of valid java code and these codes are placed in _jspService method by the JSP engine Expressions We can use this tag to output any data on the generated page. These data are automatically converted to string and printed on the output stream. shaharyar.khan555@gmail.com
  • 38. 38  Action Tag: Action tag is used to transfer the control between pages and is also used to enable the use of server side JavaBeans. Instead of using Java code, the programmer uses special JSP action tags to either link to a Java Bean set its properties, or get its properties. shaharyar.khan555@gmail.com
  • 39. 39  Syntax of JSP directives is: <%@directive attribute="value" %> Where directive may be:  page: page is used to provide the information about it. Example: <%@page import="java.util.*, java.lang.*" %>     include: include is used to include a file in the JSP page. Example: <%@ include file="/header.jsp" %>      taglib: taglib is used to use the custom tags in the JSP pages (custom tags allows us to defined our own tags). Example: <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>    shaharyar.khan555@gmail.com
  • 42. 42  Syntax of JSP Declaratives are:   <%!   //java codes    %> JSP Declaratives begins with <%! and ends %> with .We can embed any amount of java code in the JSP Declaratives. Variables and functions defined in the declaratives are class level and can be used anywhere in the JSP page.   shaharyar.khan555@gmail.com
  • 44. 44 Syntax of JSP Expressions are:   <%="Any thing"   %> JSP Expressions start with  Syntax of JSP Scriptles are with <%= and ends with  %>. Between these this you can put anything and that will converted to the String and that will be displayed. Example:   <%="Hello World!" %> Above code will display 'Hello World!'. shaharyar.khan555@gmail.com
  • 45. 45 These are the most commonly used action tags are : include forward param useBean setProperty getProperty Let discuss some tags among these …. shaharyar.khan555@gmail.com
  • 46. 46 Include directive: <%@ include file= "index.jsp" %> Include Action <jsp: include page= "index.jsp Forward Tag: <jsp:forward page= "Header.html"/> Pram Tag: <jsp:param name="result" value="<%=result%>"/> shaharyar.khan555@gmail.com
  • 47. 47 Everywhere, in any programming language , it is recommended that apply best programming practices. In JAVA, a java programmer always prefer to apply design patterns while coding. Design Patterns are specific type of coding styles that should use in specific scenarios. Let Discuss some basic Design Patterns that we should use shaharyar.khan555@gmail.com
  • 48. 48 The Singleton design pattern ensures that only one instance of a class is created. it provides a global point of access to the object and allow multiple instances in the future without affecting a singleton class's clients To ensure that only one instance of a class is created we make SingletonPattern’s instance as static Let Discuss some basic Design Patterns that we should use shaharyar.khan555@gmail.com
  • 49. 49 class SingletonClass{ private static SingletonClass instance; private SingletonClass(){ } public static synchronized SingletonClass getInstance(){ if(instance == null) instance = new SingletonClass(); return instance; } } shaharyar.khan555@gmail.com
  • 50. 50 class MyClass{ public static void main(String[] args) { SingletonClass sp = SingletonClass.getInstance(); System.out.println("first Instance: "+sp.toString()); SingletonClass sp1 = SingletonClass.getInstance(); System.out.println("2nd Instance: "+sp1.toString()); } } You will see in output that both references will be same shaharyar.khan555@gmail.com
  • 51. 51  Factory pattern comes into creational design pattern category  the main objective of the creational pattern is to instantiate an object and in Factory Pattern an interface is responsible for creating the object but the sub classes decides which class to instantiate  The Factory patterns can be used in following cases: 1. When a class does not know which class of objects it must create. 2. A class specifies its sub-classes to specify which objects to create. 3. In programmer’s language (very raw form), you can use factory pattern where you have to create an object of any one of sub-classes depending on the data provided. shaharyar.khan555@gmail.com
  • 52. 52 public class Person { // name string public String name; // gender : M or F private String gender; public String getName() { return name; } public String getGender() { return gender; } }// End of class shaharyar.khan555@gmail.com
  • 53. 53 public class Male extends Person { public Male(String fullName) { System.out.println("Hello Mr. "+fullName); } }// End of class public class Female extends Person { public Female(String fullNname) { System.out.println("Hello Ms. "+fullNname); } }// End of class shaharyar.khan555@gmail.com
  • 54. 54 public class SalutationFactory { public static void main(String args[]) { SalutationFactory factory = new SalutationFactory(); Person p = factory.getPerson(“Shaharyar”,”M”); } public Person getPerson(String name, String gender) { if (gender.equals("M")) return new Male(name); else if(gender.equals("F")) return new Female(name); else return null; } }// End of class shaharyar.khan555@gmail.com
  • 55. 55 To keep things simple you can understand it like, you have a set of ‘related’ factory method design pattern. Then you will put all those set of simple factories inside a factory pattern In abstract factory , We create a interface instead of class and then use it for the creation of objects Simply , When we have a lot of place to apply factory method then we combine all of them in a interface and use them according to our needs shaharyar.khan555@gmail.com
  • 56. 56 Facade as the name suggests means the face of the building. The people walking past the road can only see this glass face of the building. They do not know anything about it, the wiring, the pipes and other complexities. The face hides all the complexities of the building and displays a friendly face. hides the complexities of the system and provides an interface to the client from where the client can access the system In Java, the interface JDBC can be called a facade. We as users or clients create connection using the “java.sql.Connection” interface, the implementation of which we are not concerned about. The implementation is left to the vendor of driver. shaharyar.khan555@gmail.com
  • 57. 57

Editor's Notes

  1. Singleton example is wrong
  2. Singleton example is wrong