SlideShare ist ein Scribd-Unternehmen logo
1 von 25
PROGRAMMING IN ADVANCE JAVA
(J2EE)
Created By : Vikas Goyal
Basic Concepts Of Advance Java
 JVM : Java Virtual Machine
 Assertion
 JDBC : Java Database Connectivity
 Java Servlet
 JSP : Java Server Pages
Created By : Vikas Goyal
JVM : Java Virtual Machine
 Java application are typically compiled to byte code
(class file) that can run on any java virtual machine
(JVM) regardless of computer architecture.
 Before understanding what is JVM let us first know
what virtual machine is.
 A Virtual Machine is a layer of abstraction that gives
a program one simplified interface for interacting
with a variety of physical computers and their
operation system.
Created By : Vikas Goyal
JVM : Java Virtual Machine
 As the name indicates, JVM is not a real hardware
machine but a software layer which resembles an
hardware platform.
 JVM converts java byte code into machine language
and execute it.
 The byte code can be executed on any platform
where there exists JVM
Created By : Vikas Goyal
Diagram for JVM
Created By : Vikas Goyal
Components of JVM
 Byte code verifier : It checks for unusual code.
 Class loader : It loads the java class into JVM. It also reads
byte code and creates the instance of java.lang.class
 Execution engine : It helps JVM to convert byte code into
machine code.
 Garbage collector : It is the process of automatically freeing
objects that are no longer referenced by the program.
 Security manager : It constantly monitors the code.
Created By : Vikas Goyal
Assertion
 An assertion is a statement in Java that enables you to
test your assumptions about your program.
 Each assertion contains a boolean expression that you
believe will be true when the assertion executes.
 By verifying that the boolean expression is indeed true,
the assertion confirms your assumptions about the
behavior of your program, increasing your confidence
that the program is free of errors.
Created By : Vikas Goyal
Why use assertions?
 Programming by contract
 Pre-conditions
 Assert precondition as requirement of client
 Post-conditions
 Assert post-condition as effect of client method
Created By : Vikas Goyal
Syntax of using Assertion :
 There are two ways to use assertion.
 First way is : assert expression;
 Second way is : assert expression1 : expression2;
Created By : Vikas Goyal
Simple Example of Assertion in Advance Java
Created By : Vikas Goyal
JDBC : Java Database Connectivity
 JDBC provides Java applications with access to most
database systems via SQL.
 Before APIs like JDBC and ODBC, database
connectivity was tedious
With JDBC, the application programmer uses the
JDBC API
The developer never uses any proprietary APIs
• Any proprietary APIs are implemented by a JDBC
driver
• There are 4 types of JDBC Drivers
Created By : Vikas Goyal
JDBC : Java Database Connectivity
Type 1 - JDBC-ODBC Bridge
Type 2 - JDBC-Native Bridge
Type 3 - JDBC-Net Bridge
Type 4 - Direct JDBC Driver
Type 1 only runs on platforms where ODBC is available
ODBC must be configured separately
Type 2 Drivers map between a proprietary Database API and
the JDBC API
Type 3 Drivers are used with middleware products
Type 4 Drivers are written in Java
In most cases, type 4 drivers are preferred
Created By : Vikas Goyal
JDBC : Java Database Connectivity
Created By : Vikas Goyal
JDBC : Java Database Connectivity
Created By : Vikas Goyal
JDBC : Java Database Connectivity
Created By : Vikas Goyal
Java Servlet
16
 Servlets are the Java technology for serving HTTP
requests.
 They are particularly used for serving HTTP requests, but
they can be used as a basis for serving other requests,
too.
 Basic servlet functionalities implemented by the basic
HTTP servlet classes have the features for accessing
HTTP request data and managing cookies and sessions.
 Typically some other technology is used for user interface
or representation part.
 Basic servlets are not that handy for representation matters.
Created By : Vikas Goyal
Important To Know
17
 javax.servlet.Servlet
 Interface defining methods that all servlets implement
 javax.servlet.GenericServlet
 An abstract class for all Servlets
 javax.servlet.HttpServlet
 An abstract class for servlets serving HTTP requests.
 Most importantly, a Http servlet needs to implement the
doPost() and doGet() methods, which are called when a post or
get request is received.
 This is the basis for getting started with the implementation
http servlets.
Created By : Vikas Goyal
Java Servlet Web Application
18
 Servlet development (learning) life cycle
 Development
 Defining servlet classes, methods and properties
 Deployment
 Servlet mapping to web environment
 (Deployment on Tomcat)
 Execution
 Understand its execution life cycle
Created By : Vikas Goyal
“web.xml” Configuration
19
 Using the file
“web.xml” for more
specific mapping
 The file is in the
“WEB-INF” folder
 Example
 Servlet class
 HelloWorld.class
 Application context:
 http://localhost:8988/servletintro/
 Invoker class mapping
 http://localhost:8988/servletintro/servlet/HelloWorld
 Specific mapping
 http://localhost:8988/servletintro/hello
 For more mapping examples, see example “web.xml”
<servlet>
<servlet-name>HelloW</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloW</servlet-name>
<url-pattern>hello</url-pattern>
</servlet-mapping>
Created By : Vikas Goyal
Servlet Example
Created By : Vikas Goyal
JSP : Java Server Pages
 Four different elements are used in constructing JSPs
 Scripting Elements
 Implicit Objects
 Directives
 Actions
 JSPs run in two phases
 Translation Phase
 Execution Phase
 In translation phase JSP page is compiled into a servlet
 called JSP Page Implementation class
 In execution phase the compiled JSP is processed
Created By : Vikas Goyal
JSP : Java Server Pages
Created By : Vikas Goyal
JSP : Java Server Pages
 JSP Actions :
 Processed during the request processing phase.
 As opposed to JSP directives which are processed during translation
 Standard actions should be supported by J2EE compliant web servers
 Custom actions can be created using tag libraries
 The different actions are
 Include action : <jsp:include page=“inlcudedPage.jsp”>
 Forward action : <jsp:forward page=“Forwarded.html”>
Param action : <jsp:forward page=“Param2.jsp”>
<jsp:param name=“FirstName” value=“Sanjay”>
</jsp:forward>
Created By : Vikas Goyal
JSP : Java Server Pages
o useBean action : <jsp:useBean id=“myName” scope=“request”
class=“java.lang.String”>
<% firstName=“Sanjay”; %>
</jsp:useBean>
 setProperty action:<jsp:setProperty name=“myBean” property=“firstName”
value=“Sanjay”/>
 getProperty action:<jsp:getProperty name=“myBean” property=“firstName” />

Created By : Vikas Goyal
JSP : Java Server Pages
o plugIn action:
<jsp: plugin type=“applet” code=“MyApplet.class” codebase=“/”>
<jsp:params>
<jsp:param name=“myParam” value=“122”/>
</jsp:params>
<jsp:fallback><b>Unable to loadapplet</b></jsp:fallback>
</jsp:plugin>
Created By : Vikas Goyal

Weitere ähnliche Inhalte

Was ist angesagt?

Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Edureka!
 
C# programming language
C# programming languageC# programming language
C# programming languageswarnapatil
 
Hash table in java
Hash table in javaHash table in java
Hash table in javasiriindian
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOULucas Jellema
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofacmeghantaylor
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Edureka!
 

Was ist angesagt? (20)

Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Java basic
Java basicJava basic
Java basic
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
 
core java
core javacore java
core java
 
C# programming language
C# programming languageC# programming language
C# programming language
 
Hash table in java
Hash table in javaHash table in java
Hash table in java
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Java 11 to 17 : What's new !?
Java 11 to 17 : What's new !?Java 11 to 17 : What's new !?
Java 11 to 17 : What's new !?
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 

Andere mochten auch

Advanced java
Advanced java Advanced java
Advanced java NA
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010Arun Gupta
 
Wire mesh glass types
Wire mesh glass typesWire mesh glass types
Wire mesh glass typesAndrea J.
 
Why do some patents get licensed while others do not?
Why do some patents get licensed while others do not?Why do some patents get licensed while others do not?
Why do some patents get licensed while others do not?Ian McCarthy
 
Define operationally final
Define operationally finalDefine operationally final
Define operationally finalmajumalon
 
神召神學院畢業證書
神召神學院畢業證書神召神學院畢業證書
神召神學院畢業證書Man Hon Lo
 
E-MARKETING E-ZONE PPT Using ADVANCED JAVA
E-MARKETING E-ZONE PPT Using ADVANCED JAVAE-MARKETING E-ZONE PPT Using ADVANCED JAVA
E-MARKETING E-ZONE PPT Using ADVANCED JAVASudhanshu kumar Sah
 
קורות חיים מירב
קורות חיים מירבקורות חיים מירב
קורות חיים מירבMeirav Mor
 
Design Thinking: Interpretation
Design Thinking: InterpretationDesign Thinking: Interpretation
Design Thinking: InterpretationItamar Medeiros
 
Advanced Java I
Advanced Java IAdvanced Java I
Advanced Java IJay Xu
 
קורות חיים - רוח ערן קליין
קורות חיים - רוח ערן קליין קורות חיים - רוח ערן קליין
קורות חיים - רוח ערן קליין eran klein
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
OB (Emotions and Attitudes)
OB (Emotions and Attitudes)OB (Emotions and Attitudes)
OB (Emotions and Attitudes)- Freelance
 

Andere mochten auch (20)

advanced java programming(java programming tutorials)
 advanced java programming(java programming tutorials) advanced java programming(java programming tutorials)
advanced java programming(java programming tutorials)
 
Advanced java
Advanced java Advanced java
Advanced java
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
 
Wire mesh glass types
Wire mesh glass typesWire mesh glass types
Wire mesh glass types
 
Why do some patents get licensed while others do not?
Why do some patents get licensed while others do not?Why do some patents get licensed while others do not?
Why do some patents get licensed while others do not?
 
Amid sahyoun cv(updated 2016)
Amid sahyoun cv(updated 2016)Amid sahyoun cv(updated 2016)
Amid sahyoun cv(updated 2016)
 
REference letter
REference letterREference letter
REference letter
 
Define operationally final
Define operationally finalDefine operationally final
Define operationally final
 
Λαμπεντούζα- REVISED
Λαμπεντούζα- REVISEDΛαμπεντούζα- REVISED
Λαμπεντούζα- REVISED
 
神召神學院畢業證書
神召神學院畢業證書神召神學院畢業證書
神召神學院畢業證書
 
7336 16
7336 167336 16
7336 16
 
Final Paper
Final PaperFinal Paper
Final Paper
 
בגץ התאגיד.Pdf
בגץ התאגיד.Pdfבגץ התאגיד.Pdf
בגץ התאגיד.Pdf
 
E-MARKETING E-ZONE PPT Using ADVANCED JAVA
E-MARKETING E-ZONE PPT Using ADVANCED JAVAE-MARKETING E-ZONE PPT Using ADVANCED JAVA
E-MARKETING E-ZONE PPT Using ADVANCED JAVA
 
קורות חיים מירב
קורות חיים מירבקורות חיים מירב
קורות חיים מירב
 
Design Thinking: Interpretation
Design Thinking: InterpretationDesign Thinking: Interpretation
Design Thinking: Interpretation
 
Advanced Java I
Advanced Java IAdvanced Java I
Advanced Java I
 
קורות חיים - רוח ערן קליין
קורות חיים - רוח ערן קליין קורות חיים - רוח ערן קליין
קורות חיים - רוח ערן קליין
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
OB (Emotions and Attitudes)
OB (Emotions and Attitudes)OB (Emotions and Attitudes)
OB (Emotions and Attitudes)
 

Ähnlich wie Project Presentation on Advance Java

Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet backdoor
 
Ibm web sphere application server interview questions
Ibm web sphere application server interview questionsIbm web sphere application server interview questions
Ibm web sphere application server interview questionspraveen_guda
 
Web sphere liberty2
Web sphere liberty2Web sphere liberty2
Web sphere liberty2JyothirmaiG4
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music storeADEEBANADEEM
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
Java Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web developmentJava Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web developmentNicheTech Com. Solutions Pvt. Ltd.
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technologyMinal Maniar
 
Comman Gateway interface Java cgi pro.pptx
Comman Gateway interface Java cgi pro.pptxComman Gateway interface Java cgi pro.pptx
Comman Gateway interface Java cgi pro.pptxJebastinRaj1
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdfArumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdfArumugam90
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySqlDhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySqlDhyey Dattani
 

Ähnlich wie Project Presentation on Advance Java (20)

Jdbc
JdbcJdbc
Jdbc
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
 
Ibm web sphere application server interview questions
Ibm web sphere application server interview questionsIbm web sphere application server interview questions
Ibm web sphere application server interview questions
 
Web sphere liberty2
Web sphere liberty2Web sphere liberty2
Web sphere liberty2
 
Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Chapter2 j2ee
Chapter2 j2eeChapter2 j2ee
Chapter2 j2ee
 
Servlets
ServletsServlets
Servlets
 
Java Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web developmentJava Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web development
 
Ecom 1
Ecom 1Ecom 1
Ecom 1
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
4. J2EE.pptx
4. J2EE.pptx4. J2EE.pptx
4. J2EE.pptx
 
Comman Gateway interface Java cgi pro.pptx
Comman Gateway interface Java cgi pro.pptxComman Gateway interface Java cgi pro.pptx
Comman Gateway interface Java cgi pro.pptx
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 

Project Presentation on Advance Java

  • 1. PROGRAMMING IN ADVANCE JAVA (J2EE) Created By : Vikas Goyal
  • 2. Basic Concepts Of Advance Java  JVM : Java Virtual Machine  Assertion  JDBC : Java Database Connectivity  Java Servlet  JSP : Java Server Pages Created By : Vikas Goyal
  • 3. JVM : Java Virtual Machine  Java application are typically compiled to byte code (class file) that can run on any java virtual machine (JVM) regardless of computer architecture.  Before understanding what is JVM let us first know what virtual machine is.  A Virtual Machine is a layer of abstraction that gives a program one simplified interface for interacting with a variety of physical computers and their operation system. Created By : Vikas Goyal
  • 4. JVM : Java Virtual Machine  As the name indicates, JVM is not a real hardware machine but a software layer which resembles an hardware platform.  JVM converts java byte code into machine language and execute it.  The byte code can be executed on any platform where there exists JVM Created By : Vikas Goyal
  • 5. Diagram for JVM Created By : Vikas Goyal
  • 6. Components of JVM  Byte code verifier : It checks for unusual code.  Class loader : It loads the java class into JVM. It also reads byte code and creates the instance of java.lang.class  Execution engine : It helps JVM to convert byte code into machine code.  Garbage collector : It is the process of automatically freeing objects that are no longer referenced by the program.  Security manager : It constantly monitors the code. Created By : Vikas Goyal
  • 7. Assertion  An assertion is a statement in Java that enables you to test your assumptions about your program.  Each assertion contains a boolean expression that you believe will be true when the assertion executes.  By verifying that the boolean expression is indeed true, the assertion confirms your assumptions about the behavior of your program, increasing your confidence that the program is free of errors. Created By : Vikas Goyal
  • 8. Why use assertions?  Programming by contract  Pre-conditions  Assert precondition as requirement of client  Post-conditions  Assert post-condition as effect of client method Created By : Vikas Goyal
  • 9. Syntax of using Assertion :  There are two ways to use assertion.  First way is : assert expression;  Second way is : assert expression1 : expression2; Created By : Vikas Goyal
  • 10. Simple Example of Assertion in Advance Java Created By : Vikas Goyal
  • 11. JDBC : Java Database Connectivity  JDBC provides Java applications with access to most database systems via SQL.  Before APIs like JDBC and ODBC, database connectivity was tedious With JDBC, the application programmer uses the JDBC API The developer never uses any proprietary APIs • Any proprietary APIs are implemented by a JDBC driver • There are 4 types of JDBC Drivers Created By : Vikas Goyal
  • 12. JDBC : Java Database Connectivity Type 1 - JDBC-ODBC Bridge Type 2 - JDBC-Native Bridge Type 3 - JDBC-Net Bridge Type 4 - Direct JDBC Driver Type 1 only runs on platforms where ODBC is available ODBC must be configured separately Type 2 Drivers map between a proprietary Database API and the JDBC API Type 3 Drivers are used with middleware products Type 4 Drivers are written in Java In most cases, type 4 drivers are preferred Created By : Vikas Goyal
  • 13. JDBC : Java Database Connectivity Created By : Vikas Goyal
  • 14. JDBC : Java Database Connectivity Created By : Vikas Goyal
  • 15. JDBC : Java Database Connectivity Created By : Vikas Goyal
  • 16. Java Servlet 16  Servlets are the Java technology for serving HTTP requests.  They are particularly used for serving HTTP requests, but they can be used as a basis for serving other requests, too.  Basic servlet functionalities implemented by the basic HTTP servlet classes have the features for accessing HTTP request data and managing cookies and sessions.  Typically some other technology is used for user interface or representation part.  Basic servlets are not that handy for representation matters. Created By : Vikas Goyal
  • 17. Important To Know 17  javax.servlet.Servlet  Interface defining methods that all servlets implement  javax.servlet.GenericServlet  An abstract class for all Servlets  javax.servlet.HttpServlet  An abstract class for servlets serving HTTP requests.  Most importantly, a Http servlet needs to implement the doPost() and doGet() methods, which are called when a post or get request is received.  This is the basis for getting started with the implementation http servlets. Created By : Vikas Goyal
  • 18. Java Servlet Web Application 18  Servlet development (learning) life cycle  Development  Defining servlet classes, methods and properties  Deployment  Servlet mapping to web environment  (Deployment on Tomcat)  Execution  Understand its execution life cycle Created By : Vikas Goyal
  • 19. “web.xml” Configuration 19  Using the file “web.xml” for more specific mapping  The file is in the “WEB-INF” folder  Example  Servlet class  HelloWorld.class  Application context:  http://localhost:8988/servletintro/  Invoker class mapping  http://localhost:8988/servletintro/servlet/HelloWorld  Specific mapping  http://localhost:8988/servletintro/hello  For more mapping examples, see example “web.xml” <servlet> <servlet-name>HelloW</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloW</servlet-name> <url-pattern>hello</url-pattern> </servlet-mapping> Created By : Vikas Goyal
  • 20. Servlet Example Created By : Vikas Goyal
  • 21. JSP : Java Server Pages  Four different elements are used in constructing JSPs  Scripting Elements  Implicit Objects  Directives  Actions  JSPs run in two phases  Translation Phase  Execution Phase  In translation phase JSP page is compiled into a servlet  called JSP Page Implementation class  In execution phase the compiled JSP is processed Created By : Vikas Goyal
  • 22. JSP : Java Server Pages Created By : Vikas Goyal
  • 23. JSP : Java Server Pages  JSP Actions :  Processed during the request processing phase.  As opposed to JSP directives which are processed during translation  Standard actions should be supported by J2EE compliant web servers  Custom actions can be created using tag libraries  The different actions are  Include action : <jsp:include page=“inlcudedPage.jsp”>  Forward action : <jsp:forward page=“Forwarded.html”> Param action : <jsp:forward page=“Param2.jsp”> <jsp:param name=“FirstName” value=“Sanjay”> </jsp:forward> Created By : Vikas Goyal
  • 24. JSP : Java Server Pages o useBean action : <jsp:useBean id=“myName” scope=“request” class=“java.lang.String”> <% firstName=“Sanjay”; %> </jsp:useBean>  setProperty action:<jsp:setProperty name=“myBean” property=“firstName” value=“Sanjay”/>  getProperty action:<jsp:getProperty name=“myBean” property=“firstName” />  Created By : Vikas Goyal
  • 25. JSP : Java Server Pages o plugIn action: <jsp: plugin type=“applet” code=“MyApplet.class” codebase=“/”> <jsp:params> <jsp:param name=“myParam” value=“122”/> </jsp:params> <jsp:fallback><b>Unable to loadapplet</b></jsp:fallback> </jsp:plugin> Created By : Vikas Goyal