4. Description
●
J2EE architecture : 3 tier
–
Client Tier ( Web tier)
●
–
Business Tier
●
–
The Presentation layer on the client side includes j2ee
componenets such as jsp,jsf etc
Components containing business logic of the
application such as Enterprise Beans.
Database Tier
●
This tier contains the persistence API of the application
so as to talk to database
6. Servlet
●
Extends web server's functionality
●
Respond to Request from client
●
Used to generate dynamic response
●
Usually responses in HTML or Xml format
●
Most often used with HTTP protocol
7. Functioning of Servlet
●
●
●
Process or Store data that was submitted by
HTML forms
Provide dynamic content such as the result of
a database query
Manage State information
(in case of stateless HTTP protocol)
8. Packages (imports) for Servlet
●
java.io.*;
–
●
javax.servlet
–
●
Input and Output package (eg. Out.println)
Contains interaction logic between web container
and servlet
javax.servlet.http
–
Contains Http specific logic
12. ●
Loaded and instantiated
–
●
Container loads servlet during startup or when the
request is made. After loading the servlet , the
container creates the instance of the servlet when
the first request come for service ,
Initialization
–
After creating the instance the container calls init()
method. The init method is called only once in
servlets lifetime. Initialization logic goes here
13. ●
Servicing the request
–
After successful initialization , servlet will be
available to serve the request. Servlet creates
separate thread for each request
–
Service() method is called to serve the request
in short service method contains the business
logic
14. ●
Destroying the servlet
–
If the servlet is no longer needed , the servlet
container calls the destroy() method.
–
Like the init() method destroy() method also get
called only once in servlet's lifetime
–
Destroy() method releases all the resources which
were acquired previously
15. JSP (Java Server Pages)
●
Jsp is a component which generates dynamic
contents
●
Jsp is a server-side technology
●
Extension : .jsp
●
Jsp usually consist of two components
–
Static Data
●
–
Can be expressed in any text based format such as
HTML
JSP elements
●
Jsp tags , which can generates dynamic contents
17. ●
Declaration tag:
–
Declaration is used to declare and define java
variables and methods inside your jsp
–
They are initialized when the jsp page is initialized
–
The scope of the declared variables or methods is
within the jsp page
–
Syntax : <%! int a = 10; %>
19. ●
Scriptlet tag:
–
Scriptlets are block of java code
–
You can write any number of java code inside your
jsp using scriptlet
–
Syntax : <% ( Java Code ) %>
21. ●
Expression tag:
–
The code placed inside expression tag is printed
(output) , so there is no need to write out.println()
–
Mainly used to print values of variables and
methods
–
Syntax : <%= (variable or method) %>
23. ●
Directive tag:
–
Jsp directive provide directions and instructions to
the container , how to handle certain jsp
processing
–
There are 3 types of directives
●
●
●
Page directive
Include directive
Taglib directive
24. –
Page directive
●
●
●
Page directive is used to provide information about the
page
Example : <%@page language="java" %>
Here language is an attribute of the page directive
25. –
Include directive
●
●
●
Include is used to include a jsp file in the jsp page
Example : <%@ include file="/header.jsp" %>
File is an attribute which specifies which file need to
include
26. –
Taglib directive
●
●
●
Taglib directive is used to use the custom tags in the
jsp page ( custom tags allow us to define our own tags )
Example :
<%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>
27. ●
Action tag:
–
The action tag basically are used to control the
flow between pages and to use Java Beans
28. –
Some of the action tags are
●
●
●
●
●
●
●
●
Jsp:forward
Jsp:include
Jsp:useBean
Jsp:setProperty
Jsp:getPropery
Jsp:plugin
Jsp:param
Jsp:fallback