510 likes | 685 Views
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training **** <br>This Edureka tutorial on u201cAdvanced Javau201d will talk about 3 main concepts i.e. JAVA Database Connectivity, Servlets, and Java Server Pages. It will also talk about the various features, connections, statements, advantages, and need for advanced Java etc. Through this tutorial you will learn the following topics: <br><br>Introduction to J2EE <br>JDBC Architecture <br>JDBC Connections <br>JDBC Statements <br>Introduction to servlets <br>Servlet Life Cycle <br>Steps to create Servlet in Eclipse <br>Session Tracking and Cookies <br>Introduction to Java Server Pages <br>JSP Life Cycle <br>JSP Scripting Elements <br><br>Check out our Java Tutorial blog series: https://goo.gl/osrGrS <br><br>Check out our complete Youtube playlist here: https://goo.gl/gMFLx3 <br>Follow us to never miss an update in the future. <br><br>Instagram: https://www.instagram.com/edureka_learning/ <br>Facebook: https://www.facebook.com/edurekaIN/ <br>Twitter: https://twitter.com/edurekain <br>LinkedIn: https://www.linkedin.com/company/edureka
E N D
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics For Today’s Discussion 01 Introduction To Advanced Java 02 Introduction to J2EE & JDBC JDBC Fundamentals 03 04 Steps to create Application JDBC Driver Types 05 JDBC Connections 06 JDBC Statements 07 JDBC JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics For Today’s Discussion Introduction To Servlets 01 Introduction To Advanced Java 01 Servlet Life Cycle 02 Introduction to J2EE & JDBC 02 Steps to create Servlet 03 JDBC Fundamentals 03 04 Steps to create Application 04 Session Tracking 05 JDBC Driver Types Introduction to Cookies 05 JDBC Connections 06 06 Useful methods of Cookie JDBC Statements 07 Creating a cookie 07 JDBC Servlets JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics For Today’s Discussion Introduction To Servlets 01 Introduction To Advanced Java 01 01 Introduction To JSP Introduction to J2EE & JDBC 02 02 Servlet Life Cycle 02 JDBC Fundamentals JSP Life Cycle 03 03 Steps to create Servlet 04 Steps to create Application 04 Session Tracking 03 Advantages of JSP vs Servlet 05 JDBC Driver Types 05Introduction to Cookies 04 JSP Scripting Elements JDBC Connections 06 06 Useful methods of Cookie JSP JDBC Statements 07 Creating a cookie 07 JDBC Servlets JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction to ADVANCED JAva
Introduction To Advanced Java Servlets, Web, JSP, JDBC etc. Web & Enterprise Application Next level Java Programming Client & Server Architecture JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Different Editions of Java Java 2 Standard Edition Used for developing desktop applications, forms ✓ the core/base API. ✓ Helpful for client side standalone applications J2SE JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Different Editions of Java Java 2 Enterprise Edition J2EE Used for applications which run on servers, for ✓ ✓ example web sites. Used for client side Includes Servlets, Java Server Pages, Java ✓ J2SE ServerFaces JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Different Editions of Java J2ME Java Development Kit Java 2 Micro Edition J2EE ✓ Runs on resource constrained devices (small JRE is the environment within which the JVM runs ✓ ✓ scale devices) like cell phones, for example It contains a set of libraries + other files that JVM J2SE uses at runtime games. ✓ Also called Java RTE JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java 2 Enterprise Edition Standardizes an API between components and application server container A platform Independent, Simplifies the complexity of building n-tier Applications Java Centric environment for developing, building & J2EE application server and container provide the framework services deploying Web-based applications online. Why J2EE? JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction to jdbc
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 Create database Drop database SQL> CREATE DATABASE DATABASE_NAME; Create table Drop table Insert data JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax Create database Drop database SQL> DROP DATABASE DATABASE_NAME; Create table Drop table Insert data JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax Create database Drop database SQL> CREATE TABLE table_name ( column_name column_data_type, column_name column_data_type, column_name column_data_type ... ); Create table Drop table Insert data JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax Create database Drop database SQL> DROP TABLE TABLE_NAME; Create table Drop table Insert data JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC SQL Syntax Create database Drop database SQL> INSERT INTO table_name VALUES (column1, column2, ...); Create table Drop table Insert data 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 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC NATIVE API JDBC NOT PURE 100% JAVA PURE JDBC ODBC BRIDGE JDBC DRIVER TYPES
JDBC ODBC Driver Local Computer DB Vendor Driver Java Applications JDBC NATIVE API JDBC NOT pure JDBC NET pure JDBC ODBC 100% Pure BRIDGE Java Proprietary Vendor Specific Protocol Network Communication Database Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC ODBC Driver Local Computer Java Applications JDBC NATIVE API JDBC NOT pure DB Vendor Driver JDBC NET pure JDBC ODBC 100% Pure BRIDGE Java Proprietary Vendor Specific Protocol Network Communication Database Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC ODBC Driver Local Computer Middleware Server Java Applications JDBC Type 1 JDBC NATIVE API JDBC NOT pure JDBC NET pure JDBC ODBC 100% Pure BRIDGE JDBC Type 2 Java JDBC Type 3 Proprietary Vendor Specific Protocol Network Communication Database Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC ODBC Driver Local Computer Java Applications JDBC NATIVE API JDBC NOT pure JDBC NET pure JDBC ODBC 100% Pure BRIDGE Java Proprietary Vendor Specific Protocol Network Communication Database Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages Register JDBC Driver import java.sql.* ; // for standard JDBC programs DB URL Formation import java.math.* ; // for BigDecimal and BigInteger support Create connection object Close connection JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages Approach I - Class.forName() Register JDBC Driver try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch(ClassNotFoundException ex) { System.out.println("Error: unable to load driver class!"); System.exit(1); } DB URL Formation Create connection object Close connection JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages Approach II - DriverManager.registerDriver() Register JDBC Driver 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); } DB URL Formation Create connection object Close connection JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages getConnection(String url) getConnection(String url, Properties prop) Register JDBC Driver getConnection(String url, String user, String password) RDBMS MYSQL JDBC Driver Name URL DB URL Formation jdbc:mysql://hostname/ databaseName jdbc:sybase:Tds:hostname: port Number/databaseName com.mysql.jdbc.Driver Sybase com.Sybase.jdbc.SybDriver Create connection object DB2 COM.ibm.db2.jdbc.net.DB2Driverjdbc:db2:hostname:port Number/databaseName Oracle jdbc:oracle:thin:@hostname:port Number:databaseName Close connection oracle.jdbc.driver.OracleDriver JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages Register JDBC Driver Using a Database URL with a username and password Using Only a Database URL DB URL Formation Using a Database URL and a Properties Object Create connection object Close connection JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Connections Import JDBC Packages Register JDBC Driver To ensure that a connection is closed, you could provide a 'finally' block in your code DB URL Formation conn.close(); Create connection object Close connection JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JDBC Statements Statement Callable Statement Prepared Statement JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction to Servlets
What are Servlets? Server Client Request Response is sent to client Response is generated at runtime JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
What are Servlets? Robust & Scalable Creates Web Application Deployed to create Web Page Provides Interfaces & Classes Responds to any incoming requests Must be implemented to create Servlet JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Servlet Life Cycle Loading & Instantiation Start init() Initialized End of Request thread service() Handling Request destroy() End Stop 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. 3. Second new request 1. Request(new) 2. Response Client Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Hidden form field Cookies Http session URL rewriting 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. 2. Request + Cookies 1. Request 3. Response + Cookies JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Useful Methods of Cookie Class Sets the maximum age of the cookies in seconds public void setMaxAge(int expiry) Returns the name of the cookie. Name cannot be changed after creation public String getName() Returns the value of the cookie public String getValue() Changes the name of the cookie public void setName(String name) Changes the value of the cookie public void setValue(String value) JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Creating & Deleting a Cookie 1.Cookie ck=new Cookie("user",“Edureka");//creating cookie object Creation 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 Deletion 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 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction to jsp
What is JSP? It is used to create web application just like Servlet technology. Also called as extension of servlet Portable Fast Development Powerful Tracking User Flexible Easy to maintain JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Advantages of JSP over Servlets JSP ▪ Extension to Servlet ▪ It is not a extension of JSP ▪ Easy to maintain ▪ Bit complicated ▪ No need to recompile and redeploy ▪ Code needs to be recompiled ▪ Less code than servlet ▪ More code comparatively Servlets Operation JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Life Cycle of JSP Buffer JSP (dynamic content) JSP Translator Servlet Object Servlet (.java File) JRE Compiler Class file JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JSP Scripting Elements scriptlet <% java source code %> expression <%= statement %> declaration <%! field or method declaration %> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training