JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
01 Introduction To Advanced Java
02 Introduction to J2EE & JDBC
03 JDBC Fundamentals
04 Steps to create Application
05 JDBC Driver Types
06 JDBC Connections
07 JDBC Statements
Topics For Today’s Discussion
JDBC
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
01 Introduction To Advanced Java
02 Introduction to J2EE & JDBC
03 JDBC Fundamentals
04 Steps to create Application
05 JDBC Driver Types
06 JDBC Connections
07 JDBC Statements
Topics For Today’s Discussion
01 Introduction To Servlets
02 Servlet Life Cycle
03 Steps to create Servlet
04 Session Tracking
05 Introduction to Cookies
06 Useful methods of Cookie
07 Creating a cookie
JDBC
Servlets
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
01 Introduction To Advanced Java
02 Introduction to J2EE & JDBC
03 JDBC Fundamentals
04 Steps to create Application
05 JDBC Driver Types
06 JDBC Connections
07 JDBC Statements
Topics For Today’s Discussion
01 Introduction To Servlets
02 Servlet Life Cycle
03 Steps to create Servlet
04 Session Tracking
05 Introduction to Cookies
06 Useful methods of Cookie
07 Creating a cookie
01 IntroductionTo JSP
02 JSP Life Cycle
03 Advantages of JSP vs Servlet
04 JSP Scripting Elements
JDBC Servlets
JSP
Introduction to
ADVANCED JAva
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction To Advanced Java
Web & Enterprise Application
Client & Server Architecture
Servlets, Web, JSP, JDBC etc.
Next level Java Programming
J2se, j2ee, j2me
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
✓ Used for developing desktop applications, forms
the core/base API.
✓ Helpful for client side standalone applications
Different Editions of Java
Java 2 Standard
Edition
J2SE
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
✓ Used for client side
✓ Used for applications which run on servers, for
example web sites.
✓ Includes Servlets, Java Server Pages, Java
ServerFaces
J2EE
Different Editions of Java
J2SE
Java 2 Enterprise
Edition
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
J2ME
J2EE
Different Editions of Java
J2SE
Java Development Kit
✓ JRE is the environment within which the JVM runs
✓ It contains a set of libraries + other files that JVM
uses at runtime
✓ Also called Java RTE
✓ Runs on resource constrained devices (small
scale devices) like cell phones, for example
games.
Java 2 Micro
Edition
Starting j2ee
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java 2 Enterprise Edition
A platform Independent,
Java Centric environment
for developing, building &
deploying Web-based
applications online.
Simplifies the
complexity of building
n-tier Applications
Standardizes an API between
components and application
server container
J2EE application server and
container provide the
framework services
Why J2EE?
Introduction to
jdbc
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
What is JDBC?
It is a standard Java API for database-independent connectivity between the Java
programming language and a wide range of databases.
Connection 01
Create SQL 02
Execute SQL 03
Viewing 04
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Architecture
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax
Drop table
Create table
Insert data
Create database
Drop database
SQL> CREATE DATABASE DATABASE_NAME;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax
Drop table
Create table
Insert data
Create database
Drop database
SQL> DROP DATABASE DATABASE_NAME;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax
Drop table
Create table
Insert data
Create database
Drop database
SQL> CREATE TABLE table_name ( column_name
column_data_type, column_name
column_data_type, column_name
column_data_type ... );
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax
Drop table
Create table
Insert data
Create database
Drop database
SQL> DROP TABLE TABLE_NAME;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax
Drop table
Create table
Insert data
Create database
Drop database
SQL> INSERT INTO table_name VALUES
(column1, column2, ...);
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Steps to create a JDBC Application
Import the packages
Register Driver & Open Connection
Execute a Query
Extract data from result set
Clean up the environment
JDBC DRIVER
TYPES
JDBCODBC
BRIDGE
JDBCNATIVEAPI
JDBCNOTPURE
100%JAVAPURE
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBCODBC
BRIDGE
JDBCNATIVEAPI
JDBCNOTpure
JDBC ODBC DriverJDBCNETpure
100%Pure
Java
Local Computer
JavaApplicationsProprietary Vendor Specific
Protocol
Network Communication
Database Server
DB Vendor
Driver
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBCODBC
BRIDGE
JDBCNATIVEAPI
JDBCNOTpure
JDBC ODBC DriverJDBCNETpure
100%Pure
Java
Local Computer
JavaApplicationsProprietary Vendor Specific
Protocol
Network Communication
Database Server
DB Vendor
Driver
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBCODBC
BRIDGE
JDBCNATIVEAPI
JDBCNOTpure
JDBC ODBC DriverJDBCNETpure
100%Pure
Java
Local Computer
JavaApplications
Proprietary Vendor
Specific Protocol
Network Communication
Database Server
JDBC Type 1
JDBC Type 2
JDBC Type 3
Middleware Server
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBCODBC
BRIDGE
JDBCNATIVEAPI
JDBCNOTpure
JDBC ODBC Driver
JDBCNETpure
100%Pure
Java
Local Computer
JavaApplications
Proprietary Vendor Specific
Protocol
Network Communication
Database Server
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver
import java.sql.* ; // for standard JDBC programs
import java.math.* ; // for BigDecimal and BigInteger support
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver Approach I - Class.forName()
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load driver class!");
System.exit(1);
}
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver Approach II - DriverManager.registerDriver()
try {
Driver myDriver = new
oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver( myDriver );
} catch(ClassNotFoundException ex) {
System.out.println("Error: unable to load
driver class!");
System.exit(1);
}
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver
RDBMS JDBC Driver Name URL
MYSQL com.mysql.jdbc.Driver
jdbc:mysql://hostname/
databaseName
Sybase com.Sybase.jdbc.SybDriver
jdbc:sybase:Tds:hostname: port
Number/databaseName
DB2
COM.ibm.db2.jdbc.net.DB2Driver
jdbc:db2:hostname:port
Number/databaseName
Oracle oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@hostname:port
Number:databaseName
getConnection(String url)
getConnection(String url, Properties prop)
getConnection(String url, String user, String password)
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver Using a Database URL with a username and password
Using Only a Database URL
Using a Database URL and a Properties Object
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections
Create connection object
DB URL Formation
Close connection
Import JDBC Packages
Register JDBC Driver
To ensure that a connection is closed, you could
provide a 'finally' block in your code
conn.close();
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Statements
Statement
Prepared
Statement
Callable
Statement
DEMO
Introduction to
Servlets
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
What are Servlets?
Request
Response is generated at runtimeResponse is sent to client
Client Server
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
What are Servlets?
Creates Web Application
Provides Interfaces & Classes
Must be implemented to create Servlet
Robust & Scalable
Deployed to create Web Page
Responds to any incoming requests
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Servlet Life Cycle
Handling Request
Loading &
Instantiation
Initialized
End
Start
Stop
init()
service()
destroy()
End of
Request
thread
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Steps to create a simple servlet
Create and compile servlet source code
Copy servlet class file & add mappings to web.xml file
Start Apache Tomcat
Start Web Browser & Request the Servlet
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Session Tracking in Servlets
Session tracking is a way to maintain state(data) of an user.
1. Request(new)
3. Second new request
2. Response
Client
Server
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Cookies
URL
rewriting
Hidden
form field
Http
session
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Cookies in Servlet
It is a small piece of information that is persisted between the multiple client requests.
1. Request
2. Request + Cookies
3. Response + Cookies
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Useful Methods of Cookie Class
public void setMaxAge(int expiry) Sets the maximum age of the cookies in seconds
public String getName() Returns the name of the cookie. Name cannot be changed after creation
public String getValue() Returns the value of the cookie
public void setName(String name) Changes the name of the cookie
public void setValue(String value) Changes the value of the cookie
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Creating & Deleting a Cookie
Deletion
Creation
1.Cookie ck=new Cookie("user",“Edureka");//creating cookie object
2.response.addCookie(ck);//adding cookie in the response
1.Cookie ck=new Cookie("user","");//deleting value of cookie
2.ck.setMaxAge(0);//changing the maximum age to 0 seconds
3.response.addCookie(ck);//adding cookie in the response
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Pros & Cons of Cookies
Useful & Easy Technique to maintain the state
Maintained at client side
Wont work if cookie is disabled form browser
Only textual information can be set in cookie object
Introduction to
jsp
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
What is JSP?
It is used to create web application just like Servlet technology. Also called as extension of servlet
Fast Development
Tracking User
Easy to maintain
Portable
Powerful
Flexible
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Advantages of JSP over Servlets
JSP
Operation
Servlets
▪ Extension to Servlet ▪ It is not a extension of JSP
▪ No need to recompile and redeploy ▪ Code needs to be recompiled
▪ Less code than servlet ▪ More code comparatively
▪ Easy to maintain ▪ Bit complicated
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Life Cycle of JSP
Buffer
(dynamic content)
Servlet Object
JRE
JSP
Servlet (.java File)
Class file
Compiler
JSP Translator
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JSP Scripting Elements
<% java source code %>scriptlet
<%= statement %>expression
<%! field or method declaration %>declaration
Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification Training | Edureka

Advance Java Tutorial | J2EE, Java Servlets, JSP, JDBC | Java Certification Training | Edureka

  • 1.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training
  • 2.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 01 Introduction To Advanced Java 02 Introduction to J2EE & JDBC 03 JDBC Fundamentals 04 Steps to create Application 05 JDBC Driver Types 06 JDBC Connections 07 JDBC Statements Topics For Today’s Discussion JDBC
  • 3.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 01 Introduction To Advanced Java 02 Introduction to J2EE & JDBC 03 JDBC Fundamentals 04 Steps to create Application 05 JDBC Driver Types 06 JDBC Connections 07 JDBC Statements Topics For Today’s Discussion 01 Introduction To Servlets 02 Servlet Life Cycle 03 Steps to create Servlet 04 Session Tracking 05 Introduction to Cookies 06 Useful methods of Cookie 07 Creating a cookie JDBC Servlets
  • 4.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 01 Introduction To Advanced Java 02 Introduction to J2EE & JDBC 03 JDBC Fundamentals 04 Steps to create Application 05 JDBC Driver Types 06 JDBC Connections 07 JDBC Statements Topics For Today’s Discussion 01 Introduction To Servlets 02 Servlet Life Cycle 03 Steps to create Servlet 04 Session Tracking 05 Introduction to Cookies 06 Useful methods of Cookie 07 Creating a cookie 01 IntroductionTo JSP 02 JSP Life Cycle 03 Advantages of JSP vs Servlet 04 JSP Scripting Elements JDBC Servlets JSP
  • 5.
  • 6.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Introduction To Advanced Java Web & Enterprise Application Client & Server Architecture Servlets, Web, JSP, JDBC etc. Next level Java Programming
  • 7.
  • 8.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training ✓ Used for developing desktop applications, forms the core/base API. ✓ Helpful for client side standalone applications Different Editions of Java Java 2 Standard Edition J2SE
  • 9.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training ✓ Used for client side ✓ Used for applications which run on servers, for example web sites. ✓ Includes Servlets, Java Server Pages, Java ServerFaces J2EE Different Editions of Java J2SE Java 2 Enterprise Edition
  • 10.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training J2ME J2EE Different Editions of Java J2SE Java Development Kit ✓ JRE is the environment within which the JVM runs ✓ It contains a set of libraries + other files that JVM uses at runtime ✓ Also called Java RTE ✓ Runs on resource constrained devices (small scale devices) like cell phones, for example games. Java 2 Micro Edition
  • 11.
  • 12.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java 2 Enterprise Edition A platform Independent, Java Centric environment for developing, building & deploying Web-based applications online. Simplifies the complexity of building n-tier Applications Standardizes an API between components and application server container J2EE application server and container provide the framework services Why J2EE?
  • 13.
  • 14.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training What is JDBC? It is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases. Connection 01 Create SQL 02 Execute SQL 03 Viewing 04
  • 15.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Architecture
  • 16.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC SQL Syntax Drop table Create table Insert data Create database Drop database SQL> CREATE DATABASE DATABASE_NAME;
  • 17.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC SQL Syntax Drop table Create table Insert data Create database Drop database SQL> DROP DATABASE DATABASE_NAME;
  • 18.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC SQL Syntax Drop table Create table Insert data Create database Drop database SQL> CREATE TABLE table_name ( column_name column_data_type, column_name column_data_type, column_name column_data_type ... );
  • 19.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC SQL Syntax Drop table Create table Insert data Create database Drop database SQL> DROP TABLE TABLE_NAME;
  • 20.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC SQL Syntax Drop table Create table Insert data Create database Drop database SQL> INSERT INTO table_name VALUES (column1, column2, ...);
  • 21.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Steps to create a JDBC Application Import the packages Register Driver & Open Connection Execute a Query Extract data from result set Clean up the environment
  • 22.
  • 23.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBCODBC BRIDGE JDBCNATIVEAPI JDBCNOTpure JDBC ODBC DriverJDBCNETpure 100%Pure Java Local Computer JavaApplicationsProprietary Vendor Specific Protocol Network Communication Database Server DB Vendor Driver
  • 24.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBCODBC BRIDGE JDBCNATIVEAPI JDBCNOTpure JDBC ODBC DriverJDBCNETpure 100%Pure Java Local Computer JavaApplicationsProprietary Vendor Specific Protocol Network Communication Database Server DB Vendor Driver
  • 25.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBCODBC BRIDGE JDBCNATIVEAPI JDBCNOTpure JDBC ODBC DriverJDBCNETpure 100%Pure Java Local Computer JavaApplications Proprietary Vendor Specific Protocol Network Communication Database Server JDBC Type 1 JDBC Type 2 JDBC Type 3 Middleware Server
  • 26.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBCODBC BRIDGE JDBCNATIVEAPI JDBCNOTpure JDBC ODBC Driver JDBCNETpure 100%Pure Java Local Computer JavaApplications Proprietary Vendor Specific Protocol Network Communication Database Server
  • 27.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver import java.sql.* ; // for standard JDBC programs import java.math.* ; // for BigDecimal and BigInteger support
  • 28.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver Approach I - Class.forName() try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch(ClassNotFoundException ex) { System.out.println("Error: unable to load driver class!"); System.exit(1); }
  • 29.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver Approach II - DriverManager.registerDriver() try { Driver myDriver = new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver( myDriver ); } catch(ClassNotFoundException ex) { System.out.println("Error: unable to load driver class!"); System.exit(1); }
  • 30.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver RDBMS JDBC Driver Name URL MYSQL com.mysql.jdbc.Driver jdbc:mysql://hostname/ databaseName Sybase com.Sybase.jdbc.SybDriver jdbc:sybase:Tds:hostname: port Number/databaseName DB2 COM.ibm.db2.jdbc.net.DB2Driver jdbc:db2:hostname:port Number/databaseName Oracle oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@hostname:port Number:databaseName getConnection(String url) getConnection(String url, Properties prop) getConnection(String url, String user, String password)
  • 31.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver Using a Database URL with a username and password Using Only a Database URL Using a Database URL and a Properties Object
  • 32.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Connections Create connection object DB URL Formation Close connection Import JDBC Packages Register JDBC Driver To ensure that a connection is closed, you could provide a 'finally' block in your code conn.close();
  • 33.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDBC Statements Statement Prepared Statement Callable Statement
  • 34.
  • 35.
  • 36.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training What are Servlets? Request Response is generated at runtimeResponse is sent to client Client Server
  • 37.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training What are Servlets? Creates Web Application Provides Interfaces & Classes Must be implemented to create Servlet Robust & Scalable Deployed to create Web Page Responds to any incoming requests
  • 38.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Servlet Life Cycle Handling Request Loading & Instantiation Initialized End Start Stop init() service() destroy() End of Request thread
  • 39.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Steps to create a simple servlet Create and compile servlet source code Copy servlet class file & add mappings to web.xml file Start Apache Tomcat Start Web Browser & Request the Servlet
  • 40.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Session Tracking in Servlets Session tracking is a way to maintain state(data) of an user. 1. Request(new) 3. Second new request 2. Response Client Server
  • 41.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Cookies URL rewriting Hidden form field Http session
  • 42.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Cookies in Servlet It is a small piece of information that is persisted between the multiple client requests. 1. Request 2. Request + Cookies 3. Response + Cookies
  • 43.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Useful Methods of Cookie Class public void setMaxAge(int expiry) Sets the maximum age of the cookies in seconds public String getName() Returns the name of the cookie. Name cannot be changed after creation public String getValue() Returns the value of the cookie public void setName(String name) Changes the name of the cookie public void setValue(String value) Changes the value of the cookie
  • 44.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Creating & Deleting a Cookie Deletion Creation 1.Cookie ck=new Cookie("user",“Edureka");//creating cookie object 2.response.addCookie(ck);//adding cookie in the response 1.Cookie ck=new Cookie("user","");//deleting value of cookie 2.ck.setMaxAge(0);//changing the maximum age to 0 seconds 3.response.addCookie(ck);//adding cookie in the response
  • 45.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Pros & Cons of Cookies Useful & Easy Technique to maintain the state Maintained at client side Wont work if cookie is disabled form browser Only textual information can be set in cookie object
  • 46.
  • 47.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training What is JSP? It is used to create web application just like Servlet technology. Also called as extension of servlet Fast Development Tracking User Easy to maintain Portable Powerful Flexible
  • 48.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Advantages of JSP over Servlets JSP Operation Servlets ▪ Extension to Servlet ▪ It is not a extension of JSP ▪ No need to recompile and redeploy ▪ Code needs to be recompiled ▪ Less code than servlet ▪ More code comparatively ▪ Easy to maintain ▪ Bit complicated
  • 49.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Life Cycle of JSP Buffer (dynamic content) Servlet Object JRE JSP Servlet (.java File) Class file Compiler JSP Translator
  • 50.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JSP Scripting Elements <% java source code %>scriptlet <%= statement %>expression <%! field or method declaration %>declaration