SlideShare a Scribd company logo
1 of 18
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
1
1) What is Session? Explain Session Handling in JSP with
example…..
 Session:-
 Sessionsimply means a particular interval of time. Sessionisa conversional
state between client and server and it can consists of multiple request and
response between client and server.
 Sessionhandling:-
 Session Handling becomes mandatory when a requested data need to be
sustained forfurther use. Since http protocolconsiders every request as a
new one, session handling becomes important.
 Some the useful methods from session object:-
 getAttribute : it returns stored value from session object. It returns null if no
value is associated with name.
 setAttribute : It associates a value withname.
 getId : it returns unique id in the session.
 isNew : It determine if session is new to client.
 getcreationTime : It returns time at whichsession was created.
 getlastAccessedTime : It returns time at which session was accessed last by
client.
 getMaxInactiveInterval : It gets maximum amount of time session in seconds
that access session before being invalidated.
 setMaxInaxctiveInterval : It sets maximum amount of time session in
seconds between client requests before session being invalidated.
 Note:-Example writing journal program:- JSP-Session Object..
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
2
2) Write a note on servlet life cycle….
 Servlettechnology is used to create web application (resides at server side and
generates dynamic webpage). Servlet containers are responsible forhandling
requests, passing that request to the Servlet and then returning the response to the
client. The actual implementation of the container will vary from program to
program but the interface between Containers and Servlets is defined by the Servlet
APImuch in the same way as there are many JSP Containers all adhering the JSP
Specification.
 The web container maintains the life cycleof a servlet instance. Let's see the life cycle
of the servlet:-
1) Servlet class is loaded.
2) Servlet instance is created.
3) init method is invoked.
4) service method is invoked.
5) destroy method is invoked.
 As displayed in the above diagram, there are three states of a servlet: new,ready and
end. The servlet is in new state if servlet instance is created. After invoking the init()
method, Servlet comes in the ready state. In the ready state, servlet performs all the
tasks. When the web container invokes the destroy() method, it shifts to the end
state.
1) Servletclassisloaded:-
 The classloader is responsible to load the servlet class. The servlet class is
loaded when the first request for the servlet is received by the web
container.
2) Servletinstanceis created:-
 The web container creates the instance of a servlet after loading the servlet
class. The servlet instance is created only once in the servlet life cycle.
3) init methodis invoked:-
 The web container calls the init method only onceafter creating the servlet
instance. The init method is used to initialize the servlet. It is the life cycle
method of the javax.servlet.Servlet interface.
 Syntax of the init method is given below:-
public void init(ServletConfig config) throws ServletException
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
3
4) servicemethodisinvoked:-
 The web container calls the service method each time when request for
the servlet is received. If servlet is not initialized, it followsthe first three
steps as described abovethen calls the servicemethod. If servlet is
initialized, it calls the service method. Notice that servlet is initialized only
once.
 The syntax of the service method of the Servlet interface is given below:
public voidservice(ServletRequest request, ServletResponse response)
throws ServletException, IOException
5) destroymethodis invoked:-
 The web container calls the destroy method before removing the servlet
instance fromthe service. It gives the servlet an opportunity to clean up
any resource for example memory, thread etc.
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
4
3) Explain Scripting element of JSP with example….
 JSP Scripting element are written inside <% %> tags. These code inside <% %> tags
are processed by the JSP engine during translation of the JSP page. Any other text in
the JSP page is considered as HTML codeor plain text.
 Example:-
<html><head><title>My First JSP Page</title></head>
<%
int count = 0;
%>
<body>Page Count is <% out.println(++count); %>
</body></html>
 There are fivedifferent types of scripting elements:-
1) Comment <%-- comment --%>(basic)
2) Directive<%@ directive %> (basic)
3) Declaration <%! declarations %>
4) Scriptlet <% scriplets %>
5) Expression <%= expression %>
 1)Declaration:-
 We know that at the end a JSP page is translated into Servlet class. So when
we declare a variable or method in JSP inside Declaration Tag, it means the
declaration is made inside the Servlet class but outside the service(orany
other) method. Youcan declare static member, instance variable and
methods inside Declaration Tag.
 Syntax of Declaration Tag :- <%! declaration %>
 2) Expression:-
 Expression Tag is used to print out java language expression that is put
between the tags. An expression tag can hold any javalanguage expression
that can be used as an argument to the out.print() method.
 Syntax of Expression Tag:- <%= JavaExpression %>
 3) Scriptlet Tag:-
 Scriptlet Tag allows youto write java code inside JSP page. Scriptlet tag
implements the _jspService method functionality by writing script/java
code.
 Syntax of Scriptlet Tag is as follows:- <% java code %>
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
5
4) Explain JDBC Driver….
 JDBC Driveris a software component that enables java application to interact with
the database.There are 4 types of JDBCdrivers:-
1) JDBC-ODBC bridge driver
2) Native-API driver (partially java driver)
3) Network Protocol driver (fully java driver)
4) Thin driver (fully java driver)
1) JDBC-ODBC bridge driver:-
 The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The
JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function
calls. This is now discouraged because of thin driver.
 The JDBC-ODBCis also known as Type 1 driver.
 Advantages:
 Easy to use.
 can be easily connected to any database.
 Disadvantages:
 Performance degraded because JDBC method call is converted into the ODBC
function calls.
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
6
2) Native API driver:-
 The Native API driver uses the client-side libraries of the database. The driver
converts JDBCmethod calls into native calls of the database API.It is not written
entirely in java.
 The Native API driver is also knownas Type 2 driver.
 Advantage:
 Performanceupgraded than JDBC-ODBCbridge driver.
 Disadvantage:
 The Native driver needs to be installed on the each client machine.
 The Vendor client library needs to be installed on client machine.
3) NetworkProtocol driver:-
 The NetworkProtocoldriver uses middleware that converts JDBCcalls directly
or indirectly into the vendor-specific database protocol.It is fully written in java.
 It is also knownas Type 3 or Pure Java driver for database middleware.
 Advantage:
 No client side library is required because of application server that can
perform many tasks like auditing, load balancing, logging etc.
 Disadvantages:
 Networksupport is required on client machine.
 Requires database-specific coding to be done in the middle tier.
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
7
4) Thindriver:-
 The thin driver convertsJDBC calls directly into the vendor-specific database
protocol.That is why it is knownas thin driver. It is fully written in Java language.
 This driver provides the highest performance driver forthe database. Thin driver
is completely written in Javabecause of that it is known as 100% pure Javadriver
 Advantage:
 Better performance than all other drivers.
 No softwareis required at client side or server side.
 Disadvantage:
 Drivers depends on the Database.
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
8
5) Explain struts flow of controls….
 Here, we are going to understand the struts flow by 2 ways:-
1) struts 2 basic flow
2) struts 2 standard architecture and flow provided by apache struts
1) Struts 2 basic flow:-
 Let's try to understand the basic flow of struts 2 application by this simple figure:
1. User sends a request for the action
2. Controller invokes the ActionInvocation
3. ActionInvocation invokes each interceptors and action
4. A result is generated
5. The result is sent back to the ActionInvocation
6. A HttpServletResponse is generated
7. Response is sent to the user
 Struts 2 standard flow (Struts 2 architecture):-
 Let's try to understand the standard architecture of struts 2 application by this
simple figure:
Gaurav Sardhara
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
9
1. User sends a request for the action
2. Container maps the request in the web.xml file and gets the class name
of controller.
3. Container invokes the controller (StrutsPrepareAndExecuteFilter or
FilterDispatcher). Since struts2.1, it is StrutsPrepareAndExecuteFilter.
Before 2.1 it was FilterDispatcher.
4. Controller gets the information for the action from the ActionMapper
5. Controller invokes the ActionProxy
6. ActionProxy gets the information of action and interceptor stack from
the configuration manager which gets the information from the
struts.xml file.
7. ActionProxy forwards the request to the ActionInvocation
8. ActionInvocation invokes each interceptors and action
9. A result is generated
10. The result is sent back to the ActionInvocation
11. A HttpServletResponse is generated
12. Response is sent to the user
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
10
6) Explain Hibernate Annotation with example…
 The core advantage of using hibernate annotation is that you don't need to create
mapping (hbm) file. Here, hibernate annotations are used to provide the meta data.
 Example to create the hibernate application withAnnotation:-
There are 4 steps to create the hibernate application withannotation.
1) Add the jar file for oracle (if your database is oracle) and annotation
2) Create the Persistent class
3) Add mapping of Persistent class in configuration file
4) Create the class that retrieves or stores the persistent object
1) Add the jarfilefororacleand annotation:-
 For oracle youneed to add ojdbc14.jar file. For using annotation, youneed to
add:
 hibernate-commons-annotations.jar
 ejb3-persistence.jar
 hibernate-annotations.jar
2) Createthe Persistentclass:-
 Here, weare creating the same persistent class which wehave created in the
previous topic. But here, we are using annotation.
@Entity annotation marks this class as an entity.
@Table annotation specifies the table name where data of this entity is to
be persisted. If you don't use @Table annotation, hibernate willuse the
class name as the table name by default.
@Id annotation marks the identifier forthis entity.
@Column annotation specifies the details of the column for this property
or field. If @Column annotation is not specified, property name will be
used as the column name by default.
Employee.java
package com.gauravpja;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
11
@Entity
@Table(name= "emp500")
public class Employee{
@Id
private int id;
private String firstName,lastName;
public int getId(){
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
3) Add mappingofPersistentclassin configuration file:-
open the hibernate.cgf.xml file,and add an entry of mapping resource like this:
<mapping class="com.gauravpja.Employee"/>
Now the configuration file willlook like this:
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD3.0//EN"
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
12
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hbm2ddl.auto">create</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property
name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="connection.username">system</property>
<property name="connection.password">oracle</property>
<property
name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<mapping class="com.javatpoint.Employee"/>
</session-factory>
</hibernate-configuration>
4) Createthe class that retrievesorstoresthe persistentobject:-
In this class, we are simply storing the employee objectto the database. Here, we
are using the AnnotationConfiguration class to get the information of mapping
from the persistent class.
package com. gauravpja.mypackage;
package com. gauravpja;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class Test {
public static void main(String[] args) {
Session session=new AnnotationConfiguration()
.configure().buildSessionFactory().openSession();
Transaction t=session.beginTransaction();
Employeee1=new Employee();
e1.setId(1001);
e1.setFirstName("sonoo");
e1.setLastName("jaiswal");
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
13
Employeee2=new Employee();
e2.setId(1002);
e2.setFirstName("vimal");
e2.setLastName("jaiswal");
session.persist(e1);
session.persist(e2);
t.commit();
session.close();
System.out.println("successfully saved");
}
}
7) Explain Spring Framework Architecture…
 The Spring framework provides one-stop shop for javabased application on all
layers (one tier- stand-alone java application, web tier- in web application and
enterprise tier tier- Enterprise Java Beans). It is modular, means choose spring
module based on requirements, It does not inforce to add all the library files in
your projectclasspath. Here are complete module details of the Spring
Framework
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
14
 All the features of Spring frameworkare organized into 20 modules. The
diagrammatic architecture as follows:
 SpringCore:Itis corepart of Spring and consists of the followingmodules – Core,
Beans, Context and Expression Language. The brief description is as follows:
 Core: It is fundamental module of the frameworkwith IOC and Dependency
Injection withsingleton design pattern.
 Beans: This module is implementation of the factory design pattern
through BeanFactory.The BeanFactory applies IOC to separate the
application’s configuration and dependency specificationfrom actual
program logic.
 Context: It (ApplicationContext) extends the concept of BeanFactory,
adding support for - Internationalization (I18N) messages, Application
lifecycleevents and Validation. Also includes Enterprise services such as E-
mail, JNDIaccess, EJBintegration, Remoting, and Scheduling.
 ExpressionLanguage: TheSpring3.0 introduces a new expression
language – Spring Expression Language (SpEL).It is a powerfulexpression
language based on JavaServer Pages (JSP) Expression Language(EL). It is
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
15
used to write expression language querying various beans, accessing and
manipulating their properties and invoking the methods.
 Data Access: It is fundamental part of database access layer and consists of the
followingmodules – JDBC,ORM, OXM,JMS and Transaction management module.
The brief description is as follows:
 JDBC:The JDBCmodules provides a JDBC-abstraction layer that removes the
complexity of the traditional JDBC code and parsing of database-vendor
specific error code.
 ORM: The ORM module provide consistency/portability to yourcode
regardless of data access technologies based on objectoriented mapping
conceptlike Hibernate, JPA,JDOand iBatis. It provides code without
worryingabout catching exceptions specific to each persistence technology
(ex: SQLExceptionthrown by JDBCAPI).
 OXM: The OXMintroduces in Spring3.0 as separate module. It is used to
converts objectinto XML format and vice versa. The Spring OXMprovides a
uniform API to access any of these OXM(Castor,XStream, JiBX,JavaAPI for
XMLand XmlBeans) framework.
 JMS : The JMS module provides by reducing the number of line of code to
send and receivemessages. The APItake car of JMS workflow andexception
handling.
 Transaction:The Transaction module supports programmatic and
declarative transaction management for POJO classes. All the enterprise
level transaction implementation concepts can be implement in Spring.
 Web : It is corepart of Web layer and consists of the followingmodules – Web,
Web-Servlet, Web-Struts and Web-Portlet.The brief description is as follows:
 Web : This module provides basic web-oriented integration features such
as multipart file-upload functionality and the initialization of the IoC
container using servlet listeners and a web-oriented application context.
 Web-Servlet: The Web-Servlet module contains model-view-controller
(MVC) based implementation for webapplications. It provides all other
features of MVC including UI tags and data validations.
 Web-Struts:The Web-Struts module contains the support classes for
integrating a classic Struts web tier within a Spring application. It contains
the classes to integrate Struts1.x and Struts2.
 Web-Portlet: The Web-Portlet module provides the MVC implementation
to be used in a portlet environment and mirrors the functionality of Web-
Servlet module.
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
16
8) Explain AOP Concept in detail..
 Aspect-oriented programming (AOP) is an approach to programming that allows
global properties of a program to determine how it is compiled into an
executable program. AOP can be used with object-oriented programming ( OOP ).
 AOP is used in the spring Framework to-
 Providesdeclarative enterprise services , especially as a replacement for
EJBdeclarative services like declarative transaction management.
 Allow users to implement custom aspects, complementing their use of
OOP withAOP.
AOPterminologies:-
 Aspect: A cross cutting modularization across multiple objects. Aspects are
implemented by using regular classes.
 Join point: A point while executing a program, such as running an exception or a
program. In certain frameworks , a method is alwaystreated as a join point.
 Advice:Advice is an action that is taken by an aspect at a certain joint point.
“around”,”before”,”after” aredifferent types of advice.
 Pointcut:A condition / predicate that matches join points. An adviceis associated
with a point cutexpression. It is run at any joint point matched by the point cut.
 Target object:An objectthat is advised by one or more aspects.
 AOP proxy: To implement the aspect contractsor advicemethods, AOP proxy
object is created.
 Weaving: Applications or objects are linked by aspects by weaving process, for
creation of an advised object.This process can be performed at runtime.
9) Explain session Trackingmethod in servlet..
 Session simply means a particular interval of time. A session is a conversation
between the server and a client. A conversationconsists series of continuous
request and response.
 Session Tracking is a way to maintain state (data) of an user. It is also known as
session management in servlet. Session tracking used to recognize the user It is
used to recognize the particular user
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
17
 Http protocol is a stateless so weneed to maintain state using session tracking
techniques. Eachtime user requests to the server, server treats the request as the
new request. So we need to maintain the state of an user to recognize to
particular user.
 HTTP is stateless that means each request is considered as the new request. It is
shown in the figure given below:
 Session Tracking Techniques(Method):-
There are four techniques used in Session tracking:
1) Cookies
2) Hidden Form Field
3) URL Rewriting
4) HttpSession
1) Cookies:
 Youcan use HTTP cookies to store information.
 Cookies will bestored at browser side.
2) Hidden form fields:
 By using hidden form fields we can insert information in the webpages
and these information willbe sent to the server. These fields are not
visible directly to the user, but can be viewed using view source
option from the browsers.
 The hidden form fields are as given below:-
<input type='hidden' name='siteName' value='java2novice'/>
J2EE Assignment-Edited By:-GauravPrajapati (Sardhara)
18
2) URL rewriting:
 With this method, the information is carried through url as
request parameters. In general added parameter will be sessionid,
userid.
3) HttpSession:
 Using HttpSession, we can store information at server side. HttpSession
provides methods to handle session related information.
10) Explain JDBC with JSP with Example..
 Only write Program – jsp-tabular format from mysql database..

More Related Content

What's hot

What's hot (20)

Servlet lifecycle
Servlet lifecycleServlet lifecycle
Servlet lifecycle
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Java servlets
Java servletsJava servlets
Java servlets
 
Java servlets
Java servletsJava servlets
Java servlets
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
SERVIET
SERVIETSERVIET
SERVIET
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
JDBC
JDBCJDBC
JDBC
 
Advance Java
Advance JavaAdvance Java
Advance Java
 
Servlets
ServletsServlets
Servlets
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Knowledge Sharing : Java Servlet
Knowledge Sharing : Java ServletKnowledge Sharing : Java Servlet
Knowledge Sharing : Java Servlet
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
 
Servlets
ServletsServlets
Servlets
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
 

Similar to J2EE-assignment (20)

ajava unit 1.pptx
ajava unit 1.pptxajava unit 1.pptx
ajava unit 1.pptx
 
Advanced java+JDBC+Servlet
Advanced java+JDBC+ServletAdvanced java+JDBC+Servlet
Advanced java+JDBC+Servlet
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3
 
Bt0083 server side programing
Bt0083 server side programing Bt0083 server side programing
Bt0083 server side programing
 
Java Servlet
Java ServletJava Servlet
Java Servlet
 
Major project report
Major project reportMajor project report
Major project report
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Servlets & jdbc
Servlets & jdbcServlets & jdbc
Servlets & jdbc
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
Server side programming
Server side programming Server side programming
Server side programming
 
Atul & shubha goswami jsp
Atul & shubha goswami jspAtul & shubha goswami jsp
Atul & shubha goswami jsp
 
WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES Servlet
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 
Servlet.pptx
Servlet.pptxServlet.pptx
Servlet.pptx
 
Servlet.pptx
Servlet.pptxServlet.pptx
Servlet.pptx
 

More from gaurav sardhara

More from gaurav sardhara (6)

Seo
SeoSeo
Seo
 
Asp.net assignment-gp
Asp.net assignment-gpAsp.net assignment-gp
Asp.net assignment-gp
 
SEO_beginner
SEO_beginnerSEO_beginner
SEO_beginner
 
SEO_Topic-1
SEO_Topic-1SEO_Topic-1
SEO_Topic-1
 
Asp.net basic program
Asp.net basic programAsp.net basic program
Asp.net basic program
 
Ch 5-network devices
Ch 5-network devicesCh 5-network devices
Ch 5-network devices
 

Recently uploaded

Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleCeline George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17Celine George
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 

Recently uploaded (20)

Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Multi Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP ModuleMulti Domain Alias In the Odoo 17 ERP Module
Multi Domain Alias In the Odoo 17 ERP Module
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17How to Manage Engineering to Order in Odoo 17
How to Manage Engineering to Order in Odoo 17
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 

J2EE-assignment

  • 1. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 1 1) What is Session? Explain Session Handling in JSP with example…..  Session:-  Sessionsimply means a particular interval of time. Sessionisa conversional state between client and server and it can consists of multiple request and response between client and server.  Sessionhandling:-  Session Handling becomes mandatory when a requested data need to be sustained forfurther use. Since http protocolconsiders every request as a new one, session handling becomes important.  Some the useful methods from session object:-  getAttribute : it returns stored value from session object. It returns null if no value is associated with name.  setAttribute : It associates a value withname.  getId : it returns unique id in the session.  isNew : It determine if session is new to client.  getcreationTime : It returns time at whichsession was created.  getlastAccessedTime : It returns time at which session was accessed last by client.  getMaxInactiveInterval : It gets maximum amount of time session in seconds that access session before being invalidated.  setMaxInaxctiveInterval : It sets maximum amount of time session in seconds between client requests before session being invalidated.  Note:-Example writing journal program:- JSP-Session Object..
  • 2. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 2 2) Write a note on servlet life cycle….  Servlettechnology is used to create web application (resides at server side and generates dynamic webpage). Servlet containers are responsible forhandling requests, passing that request to the Servlet and then returning the response to the client. The actual implementation of the container will vary from program to program but the interface between Containers and Servlets is defined by the Servlet APImuch in the same way as there are many JSP Containers all adhering the JSP Specification.  The web container maintains the life cycleof a servlet instance. Let's see the life cycle of the servlet:- 1) Servlet class is loaded. 2) Servlet instance is created. 3) init method is invoked. 4) service method is invoked. 5) destroy method is invoked.  As displayed in the above diagram, there are three states of a servlet: new,ready and end. The servlet is in new state if servlet instance is created. After invoking the init() method, Servlet comes in the ready state. In the ready state, servlet performs all the tasks. When the web container invokes the destroy() method, it shifts to the end state. 1) Servletclassisloaded:-  The classloader is responsible to load the servlet class. The servlet class is loaded when the first request for the servlet is received by the web container. 2) Servletinstanceis created:-  The web container creates the instance of a servlet after loading the servlet class. The servlet instance is created only once in the servlet life cycle. 3) init methodis invoked:-  The web container calls the init method only onceafter creating the servlet instance. The init method is used to initialize the servlet. It is the life cycle method of the javax.servlet.Servlet interface.  Syntax of the init method is given below:- public void init(ServletConfig config) throws ServletException
  • 3. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 3 4) servicemethodisinvoked:-  The web container calls the service method each time when request for the servlet is received. If servlet is not initialized, it followsthe first three steps as described abovethen calls the servicemethod. If servlet is initialized, it calls the service method. Notice that servlet is initialized only once.  The syntax of the service method of the Servlet interface is given below: public voidservice(ServletRequest request, ServletResponse response) throws ServletException, IOException 5) destroymethodis invoked:-  The web container calls the destroy method before removing the servlet instance fromthe service. It gives the servlet an opportunity to clean up any resource for example memory, thread etc.
  • 4. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 4 3) Explain Scripting element of JSP with example….  JSP Scripting element are written inside <% %> tags. These code inside <% %> tags are processed by the JSP engine during translation of the JSP page. Any other text in the JSP page is considered as HTML codeor plain text.  Example:- <html><head><title>My First JSP Page</title></head> <% int count = 0; %> <body>Page Count is <% out.println(++count); %> </body></html>  There are fivedifferent types of scripting elements:- 1) Comment <%-- comment --%>(basic) 2) Directive<%@ directive %> (basic) 3) Declaration <%! declarations %> 4) Scriptlet <% scriplets %> 5) Expression <%= expression %>  1)Declaration:-  We know that at the end a JSP page is translated into Servlet class. So when we declare a variable or method in JSP inside Declaration Tag, it means the declaration is made inside the Servlet class but outside the service(orany other) method. Youcan declare static member, instance variable and methods inside Declaration Tag.  Syntax of Declaration Tag :- <%! declaration %>  2) Expression:-  Expression Tag is used to print out java language expression that is put between the tags. An expression tag can hold any javalanguage expression that can be used as an argument to the out.print() method.  Syntax of Expression Tag:- <%= JavaExpression %>  3) Scriptlet Tag:-  Scriptlet Tag allows youto write java code inside JSP page. Scriptlet tag implements the _jspService method functionality by writing script/java code.  Syntax of Scriptlet Tag is as follows:- <% java code %>
  • 5. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 5 4) Explain JDBC Driver….  JDBC Driveris a software component that enables java application to interact with the database.There are 4 types of JDBCdrivers:- 1) JDBC-ODBC bridge driver 2) Native-API driver (partially java driver) 3) Network Protocol driver (fully java driver) 4) Thin driver (fully java driver) 1) JDBC-ODBC bridge driver:-  The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.  The JDBC-ODBCis also known as Type 1 driver.  Advantages:  Easy to use.  can be easily connected to any database.  Disadvantages:  Performance degraded because JDBC method call is converted into the ODBC function calls.
  • 6. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 6 2) Native API driver:-  The Native API driver uses the client-side libraries of the database. The driver converts JDBCmethod calls into native calls of the database API.It is not written entirely in java.  The Native API driver is also knownas Type 2 driver.  Advantage:  Performanceupgraded than JDBC-ODBCbridge driver.  Disadvantage:  The Native driver needs to be installed on the each client machine.  The Vendor client library needs to be installed on client machine. 3) NetworkProtocol driver:-  The NetworkProtocoldriver uses middleware that converts JDBCcalls directly or indirectly into the vendor-specific database protocol.It is fully written in java.  It is also knownas Type 3 or Pure Java driver for database middleware.  Advantage:  No client side library is required because of application server that can perform many tasks like auditing, load balancing, logging etc.  Disadvantages:  Networksupport is required on client machine.  Requires database-specific coding to be done in the middle tier.
  • 7. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 7 4) Thindriver:-  The thin driver convertsJDBC calls directly into the vendor-specific database protocol.That is why it is knownas thin driver. It is fully written in Java language.  This driver provides the highest performance driver forthe database. Thin driver is completely written in Javabecause of that it is known as 100% pure Javadriver  Advantage:  Better performance than all other drivers.  No softwareis required at client side or server side.  Disadvantage:  Drivers depends on the Database.
  • 8. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 8 5) Explain struts flow of controls….  Here, we are going to understand the struts flow by 2 ways:- 1) struts 2 basic flow 2) struts 2 standard architecture and flow provided by apache struts 1) Struts 2 basic flow:-  Let's try to understand the basic flow of struts 2 application by this simple figure: 1. User sends a request for the action 2. Controller invokes the ActionInvocation 3. ActionInvocation invokes each interceptors and action 4. A result is generated 5. The result is sent back to the ActionInvocation 6. A HttpServletResponse is generated 7. Response is sent to the user  Struts 2 standard flow (Struts 2 architecture):-  Let's try to understand the standard architecture of struts 2 application by this simple figure: Gaurav Sardhara
  • 9. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 9 1. User sends a request for the action 2. Container maps the request in the web.xml file and gets the class name of controller. 3. Container invokes the controller (StrutsPrepareAndExecuteFilter or FilterDispatcher). Since struts2.1, it is StrutsPrepareAndExecuteFilter. Before 2.1 it was FilterDispatcher. 4. Controller gets the information for the action from the ActionMapper 5. Controller invokes the ActionProxy 6. ActionProxy gets the information of action and interceptor stack from the configuration manager which gets the information from the struts.xml file. 7. ActionProxy forwards the request to the ActionInvocation 8. ActionInvocation invokes each interceptors and action 9. A result is generated 10. The result is sent back to the ActionInvocation 11. A HttpServletResponse is generated 12. Response is sent to the user
  • 10. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 10 6) Explain Hibernate Annotation with example…  The core advantage of using hibernate annotation is that you don't need to create mapping (hbm) file. Here, hibernate annotations are used to provide the meta data.  Example to create the hibernate application withAnnotation:- There are 4 steps to create the hibernate application withannotation. 1) Add the jar file for oracle (if your database is oracle) and annotation 2) Create the Persistent class 3) Add mapping of Persistent class in configuration file 4) Create the class that retrieves or stores the persistent object 1) Add the jarfilefororacleand annotation:-  For oracle youneed to add ojdbc14.jar file. For using annotation, youneed to add:  hibernate-commons-annotations.jar  ejb3-persistence.jar  hibernate-annotations.jar 2) Createthe Persistentclass:-  Here, weare creating the same persistent class which wehave created in the previous topic. But here, we are using annotation. @Entity annotation marks this class as an entity. @Table annotation specifies the table name where data of this entity is to be persisted. If you don't use @Table annotation, hibernate willuse the class name as the table name by default. @Id annotation marks the identifier forthis entity. @Column annotation specifies the details of the column for this property or field. If @Column annotation is not specified, property name will be used as the column name by default. Employee.java package com.gauravpja; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table;
  • 11. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 11 @Entity @Table(name= "emp500") public class Employee{ @Id private int id; private String firstName,lastName; public int getId(){ return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } 3) Add mappingofPersistentclassin configuration file:- open the hibernate.cgf.xml file,and add an entry of mapping resource like this: <mapping class="com.gauravpja.Employee"/> Now the configuration file willlook like this: hibernate.cfg.xml <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD3.0//EN"
  • 12. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 12 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hbm2ddl.auto">create</property> <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property> <property name="connection.username">system</property> <property name="connection.password">oracle</property> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <mapping class="com.javatpoint.Employee"/> </session-factory> </hibernate-configuration> 4) Createthe class that retrievesorstoresthe persistentobject:- In this class, we are simply storing the employee objectto the database. Here, we are using the AnnotationConfiguration class to get the information of mapping from the persistent class. package com. gauravpja.mypackage; package com. gauravpja; import org.hibernate.*; import org.hibernate.cfg.*; public class Test { public static void main(String[] args) { Session session=new AnnotationConfiguration() .configure().buildSessionFactory().openSession(); Transaction t=session.beginTransaction(); Employeee1=new Employee(); e1.setId(1001); e1.setFirstName("sonoo"); e1.setLastName("jaiswal");
  • 13. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 13 Employeee2=new Employee(); e2.setId(1002); e2.setFirstName("vimal"); e2.setLastName("jaiswal"); session.persist(e1); session.persist(e2); t.commit(); session.close(); System.out.println("successfully saved"); } } 7) Explain Spring Framework Architecture…  The Spring framework provides one-stop shop for javabased application on all layers (one tier- stand-alone java application, web tier- in web application and enterprise tier tier- Enterprise Java Beans). It is modular, means choose spring module based on requirements, It does not inforce to add all the library files in your projectclasspath. Here are complete module details of the Spring Framework
  • 14. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 14  All the features of Spring frameworkare organized into 20 modules. The diagrammatic architecture as follows:  SpringCore:Itis corepart of Spring and consists of the followingmodules – Core, Beans, Context and Expression Language. The brief description is as follows:  Core: It is fundamental module of the frameworkwith IOC and Dependency Injection withsingleton design pattern.  Beans: This module is implementation of the factory design pattern through BeanFactory.The BeanFactory applies IOC to separate the application’s configuration and dependency specificationfrom actual program logic.  Context: It (ApplicationContext) extends the concept of BeanFactory, adding support for - Internationalization (I18N) messages, Application lifecycleevents and Validation. Also includes Enterprise services such as E- mail, JNDIaccess, EJBintegration, Remoting, and Scheduling.  ExpressionLanguage: TheSpring3.0 introduces a new expression language – Spring Expression Language (SpEL).It is a powerfulexpression language based on JavaServer Pages (JSP) Expression Language(EL). It is
  • 15. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 15 used to write expression language querying various beans, accessing and manipulating their properties and invoking the methods.  Data Access: It is fundamental part of database access layer and consists of the followingmodules – JDBC,ORM, OXM,JMS and Transaction management module. The brief description is as follows:  JDBC:The JDBCmodules provides a JDBC-abstraction layer that removes the complexity of the traditional JDBC code and parsing of database-vendor specific error code.  ORM: The ORM module provide consistency/portability to yourcode regardless of data access technologies based on objectoriented mapping conceptlike Hibernate, JPA,JDOand iBatis. It provides code without worryingabout catching exceptions specific to each persistence technology (ex: SQLExceptionthrown by JDBCAPI).  OXM: The OXMintroduces in Spring3.0 as separate module. It is used to converts objectinto XML format and vice versa. The Spring OXMprovides a uniform API to access any of these OXM(Castor,XStream, JiBX,JavaAPI for XMLand XmlBeans) framework.  JMS : The JMS module provides by reducing the number of line of code to send and receivemessages. The APItake car of JMS workflow andexception handling.  Transaction:The Transaction module supports programmatic and declarative transaction management for POJO classes. All the enterprise level transaction implementation concepts can be implement in Spring.  Web : It is corepart of Web layer and consists of the followingmodules – Web, Web-Servlet, Web-Struts and Web-Portlet.The brief description is as follows:  Web : This module provides basic web-oriented integration features such as multipart file-upload functionality and the initialization of the IoC container using servlet listeners and a web-oriented application context.  Web-Servlet: The Web-Servlet module contains model-view-controller (MVC) based implementation for webapplications. It provides all other features of MVC including UI tags and data validations.  Web-Struts:The Web-Struts module contains the support classes for integrating a classic Struts web tier within a Spring application. It contains the classes to integrate Struts1.x and Struts2.  Web-Portlet: The Web-Portlet module provides the MVC implementation to be used in a portlet environment and mirrors the functionality of Web- Servlet module.
  • 16. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 16 8) Explain AOP Concept in detail..  Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. AOP can be used with object-oriented programming ( OOP ).  AOP is used in the spring Framework to-  Providesdeclarative enterprise services , especially as a replacement for EJBdeclarative services like declarative transaction management.  Allow users to implement custom aspects, complementing their use of OOP withAOP. AOPterminologies:-  Aspect: A cross cutting modularization across multiple objects. Aspects are implemented by using regular classes.  Join point: A point while executing a program, such as running an exception or a program. In certain frameworks , a method is alwaystreated as a join point.  Advice:Advice is an action that is taken by an aspect at a certain joint point. “around”,”before”,”after” aredifferent types of advice.  Pointcut:A condition / predicate that matches join points. An adviceis associated with a point cutexpression. It is run at any joint point matched by the point cut.  Target object:An objectthat is advised by one or more aspects.  AOP proxy: To implement the aspect contractsor advicemethods, AOP proxy object is created.  Weaving: Applications or objects are linked by aspects by weaving process, for creation of an advised object.This process can be performed at runtime. 9) Explain session Trackingmethod in servlet..  Session simply means a particular interval of time. A session is a conversation between the server and a client. A conversationconsists series of continuous request and response.  Session Tracking is a way to maintain state (data) of an user. It is also known as session management in servlet. Session tracking used to recognize the user It is used to recognize the particular user
  • 17. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 17  Http protocol is a stateless so weneed to maintain state using session tracking techniques. Eachtime user requests to the server, server treats the request as the new request. So we need to maintain the state of an user to recognize to particular user.  HTTP is stateless that means each request is considered as the new request. It is shown in the figure given below:  Session Tracking Techniques(Method):- There are four techniques used in Session tracking: 1) Cookies 2) Hidden Form Field 3) URL Rewriting 4) HttpSession 1) Cookies:  Youcan use HTTP cookies to store information.  Cookies will bestored at browser side. 2) Hidden form fields:  By using hidden form fields we can insert information in the webpages and these information willbe sent to the server. These fields are not visible directly to the user, but can be viewed using view source option from the browsers.  The hidden form fields are as given below:- <input type='hidden' name='siteName' value='java2novice'/>
  • 18. J2EE Assignment-Edited By:-GauravPrajapati (Sardhara) 18 2) URL rewriting:  With this method, the information is carried through url as request parameters. In general added parameter will be sessionid, userid. 3) HttpSession:  Using HttpSession, we can store information at server side. HttpSession provides methods to handle session related information. 10) Explain JDBC with JSP with Example..  Only write Program – jsp-tabular format from mysql database..