WT 4th and 5th Unit
WT 4th and 5th Unit
Spring
4
UNIT Que4.1.
Spring Core
PART-1
Basics : Spring Dependency
What is Spring Core and what are its
Injection Concept.
advantages ?
Spring Answer
1. i a lightweight
Springgis
reomeworks because framework.
It can be
it provides support tothought of as a framework
a8 Struts, Hibernate, Tapestry, JB, JSF,etc, various franoworks such
CONTENTS 2
mhe framework carn be defined as a structure
where we find solution of
the various technical problems.
Part-l : Spring Core Basics : Spring...... The Spring framework comprises several modules such as
.4-2I to 4-51 I0C, AOP.
Dependency Injection Concepts DAO,Context, ORM, WEB MVC etc.
Advantages of Spring framework:
Part-2 : Introduction to Design Patterns,
Factory Design Pattern, Strategy 4-6I to 4-81 KPredefined templates :Spring framework provides templates for
Design Pattern DBC, Hibernate, JPA etc.,technologies. So there is no need tÍ write
too much code. It hides the basic steps of these technologies.
Part-3 : Spring Inversion of Control Loose coupling :The Spring applications are loosely coupled because
.4-9I to 4-10I of dependency injection.
Part-4 : AOP
.4-10I to4-111 & Easy to test : The dependency injection makes easier to test the
Part-5 : Bean Scopes : application. The EJB or Struts application require server to run the
Singleton, .4-11Ito 4-151 application but Spring framework does not require server.
Prototype, Request, 4 Lightweight : Spring framewo: kis lightweight because ofits POJO
Session, Application implementation. The Spring framework does not force the programner
Part-6 : WebSocket.. to inherit any class or implement any interface. That is why it is said
.. 4-151 to 4-171 non-invasive.
Part-7 : Autowiring 5. Fast development : The dependency injection feature of Spring
Part-8 : Annotations
.4-17Ito4-181 framework and it support to various frameworks makes the easy
development of JavaEE application.
4-181 to 4-191
Part-9 : Life Cycle Call Backs Que 4.2. What is Spring framework ? Discuss feature of the
... 4-19I to 4-211
Part-10 : Bean Spring. |AKTU 2021-22, Marks 10
Configuration Styles e*****..n.. 4 21Ito 4-23I
Answer
Spring framework:
The Spring framework is an open-source Java framework that provides
comprehensive support for building enterprise -level applications.
develop robust, scalable,
4-11 (MCA-Sem-3) lt offers a lightweight and modular approa-h to
and maintainable applications.
HIMCA-Sem-3)
Web Technology 43I (MCA-Sem-3) Spring
coupling between classes can be
Loose
injectorpossible
focuses on the concept off
3 The Spring framework
and inversion of control
(IoC). dependency injection for
common functionality and the
required implementation.
by
definingthe interfaces
willinstantiate
objects of
4 This enables loose coupling and promoting testability and
Features of Spring framework: reusability. 5
Thetask of instantiating objectssis done by the
the configurations specified by the developer. container accordingto
The core principle of
L Inversion of Control (LoC): the
framework is loC, which allows the framework to manage the
creation
Spring Que4.4. What are the types of dependency injection in
Spring ?
and lifecycle of objects. | 6omuation to
2 Aspect-Oriented Programming (AOP) :AOP enables
of concerns such as logging, transaction management,
dytuton
modularization Answer
There aretwo types of spring dependency injection. They are:
caching. security, and
L Setter Dependency Injection ((SDI):This is the simpler of thetwo DI
R Spring container It manages the creation, configuration, and methods. In this, the DI will be injected with the help of setter and/or
lifecycle of objects (beans). getter methods.. Now to set the DI as SDI in the bean, it is done through
Spring MVC: Spring MVC is a web framework built on ton of the the bean-configuration file For this,the propertyto be set withthe SDI
Spring framework, providing arobust and flexible MVC (Model-View. is declared under the <property> tag in the bean-config file.
Controller) architecture. Aaiao u/iNyak on , Constructor Dependency Injection (CD): In this, the DI will be
Data access and integration :Spring provides powerful abstractions iniected with the help of constructors. Now to set the Dl as CDl in bean,
and integrations for working with various data access technologies. itis done through the bean-configuration file For this, the property to be
6 Security: Spring security is a highly flexible and customizable security set with the CDI is declared under the <constructor-arg> tag in the
framework. bean-config file.
7. Testability and test integration :The Spring framework promotes
testability by supporting integratiÍn testing and providing mock objects Compare constructor injection and setter injection in
Que 4.5.
and testing utilities. AKTU2022-23, Marks 10
spring with suitable example.
Que 43. What is dependency injection in Spring ? How does it
work ? Answer
Setter
Answer S. No. Aspect Constructor
injection
injection
Dependency injection: are Dependencies are
L Dependency Injection (DI) is a design pattern that removes the 1 Definition Dependencies provided to a class
dependency from the programming code so that it can be easy to manage provided to a class setter
through
andtest the application. through itsconstructor. methods.
2. Dependency Injection makes our programming code loosely coupled. can
numberEach dependency
Working : 2. Dependency The order and independently
constructor be set corresponding
L Suppose class One needs the object ofclass Two to order of using
a method, then class One is said to be instantiate or operate parameters define the setter methods.
dependent on class Two. dependencies.
2. Now though it might appear okay to depend a
module on the other Dul Dependencies can be
in the real world, this could lead to a dependencies are and they can
failure. Hence such dependencies needlottoofbeproblems, including syStem
3. Required All and they optional,
later using setter
3 avoided. |dependencies required,
providedat the be set
Spring 10Cresolves such dependencies with Dependency be of objectmethods.
Injection, POLI
BE
R* must
which mnakes the code easier to time
test and reuse. instantiation.
Web Technology 45I (MCA-Sem-3) L6I(MCA-Sem-3)
4-i7n1dependent
(MCA-Selymth.e3m Spring
Web Technology
2 Strategy : Defines a family of algorithms and makes You can annotate a method with @Bean or configure it using
interchangeable, allowingthe algorithm to vary XML to indicate that it is a factory method.
clients that use it.
3 Template method : Defines the skeleton of an
from ii The method can then instantiate and configure an object and
return it.
algorithm
class, allowing subclassesto override specific steps of thee in abase iv. Spring will manage the lifecycle of the object and use the
4
without changing its structure.
Iterator: Provides a way to access elementss of an
algorithm factory method to create instances.
aggregate object
sequentially without exposing its underlying representation Oue 4.8. Explain the Strategy Design Pattern and its relevance
5. State: Allows an objectto alteriits behavior when itss in Spring.
the behavior to the current state.
internal
changes, encapsulating each state in aseparate class and state
delegatine Answer
A Strategy Design Pattern:
Que 4.7. What is the Factory Design Pattern ? How is it 1 The Strategy Design Pattern is a way of organizing and managing
implemented in Spring? different algorithms or strategies.
Answer 2. Each strategy is encapsulated separately and can be easily swapped
with others.
A Factory Design Pattern : runtime without
1. The Factory Design Pattern is a
3. It allows you to change strategies dynamically at
way of creating objects where we being tied to specific implementations.
have a special class that handles the creation, switch behavior based on
decide the exact type of object to create. but it lets subclasses 4. This flexibility is useful when you want to
2 It
different conditions or requirements.
uses an abstract factory class that has Design Pattern brings benefits like
creating objects. one or more methods for 5. In Spring, using the Strategy code organization, and easier
increased flexibility, modular
3 These factory methods are
related classes. responsible for creating instances of maintenance.
algorithms or
and handle different
4. In Spring, the Factory 6 It helps you encapsulate encourages code reuse, and simplifies
Design
the Dependency Injection (DI)Pattern is commonly used along with behaviors independently,
strategies.
container. configuration and switching between
5. It helps manage the Pattern in Spring: Here's how the
Spring to handle thecreation and configuration of objects by Design
object creation process based on the allowing B. Relevance of Strategy relevant in Spring :
factories and dependencies. defined Strategy Design Pattern is strategies for
B. Business Logic: In Spring, you can define differentstrategies and
Implementation of Factory Design
following ways to implement the Pattern : Spring provides
1.
implementing business logic. By
encapsulating these
components, you can easily switch
between
FactoryBean Interface : Factory Design Pattern :
1. injecting them into your
your core code.
them without changing options to manage
Spring provides the Profiles : Spring provides profiles. You can
define a factory for FactoryBean interface that allows you to 2. Bean Scopes and
on different scopes
and
You can create a creating objects. object instances based for specific scopes or profiles, and Spring
define different strategies appropriate strategy based on
custom
interface, override implementation
the get0bject()
instance of the desired
of the
method, andFactoryBean will handle creating and injecting the
i.
object. return an the context.
Configuration : With Spring's
conditional bean
Spring will manage the lifecycle of Conditional creating beans based
tocreate instances as needed. the factory bean 3. can define conditions for strategies as
and use it configuration, you multiple
you define conditions
2 Factory Method: criteria. This lets deactivate them based on
on specific activate or factors.
i. Spring allows you to define separate beans and values, or other
presence, property
configuration classes or XML factory methods like class
,configuration files. in your
L101(MCA-Sem-3)
Web Technology 4-9I (MCA-Sem-3) Spring
iL Itaalso allows for dependencies to be replaced with mocks or stubs in unit
PART-3
tests without modifying the original code.
DI decouples code from specific implementations, making it easy to
Spring Inversion of Control. swap or update dependencies without :affecting the rest of the system.
DI reduces the complexity. and interdependence of your code,
V.
easier to understand, debug, and refactor.
making it
Que 49. Explain the concept of Inversion of Control (IoC) in Adyantages of using Spring for inversion of control :
Spring.
Inyersion of control maintain the creation, configuration, provisioning
Answer and lifecycle of all container-managed objects separately from the code
1 Spring loC (Inversion of Control) where they are referenced.
Framework. Container is the core of Spring i IOC decouples the execution of a task from its implementation.
2. It creates the objects, I0C makes it easier to switch between different implementations.
manages their entire lifeconfigures
cycle.
and assembles their
dependencies,
3. The iv. IOC gives greater modularity of a program.
Container uses Dependency Injection (DI) to IOC makes greater ease in testing a program by isolating a component
components that make up the application, manage the V
or mocking its dependencies, and allowing components to communicate
4. It gets the
or Java Codeinformation about the objects from a through contracts.
or Java
are called Beans. configuration
Annotations and Java POJO file(XML)
class. These vi. IOC makes your code loosely coupled.
objects to write great unit tests.
v. IOC makes it easy for the programmer
5.
Since the Controlling of Java
the developers, hence the objects and their lifecycle is not done by
6. The followings are some ofname Inversion Of Control.
the main features of PART-4
i
Creating Object for us, Spring loC,
AOP.
Managing our objects,
iüi. Helping our
application to be
iv. Managing dependencies configurable, Aspect-Oriented Programming(AOP)
work in
7. There are two types of loC Que 4.11. How does
i containers. They are: Spring ? Provide examples.
BeanFactory OR
Programming in spring framework.
ApplicationContext Wlustrate Aspect Oriented AKTU2022-23, Marks 10
Que 4.10. What are the
advantages
injection and inversion of control ? of using Spring for r dependency Answer
Programming (AOP): the breaking of
code
Answer Aspect Oriented Programming (AOP) is defined as unit of modularity.
Advantages of using Spring for 1 Aspect Oriented aspect is the key
modules where the
dependency into different cross-cutting concerns in an application.
modulariinjection:
i
Dependency Injection (DI) across multiple
improvesmaintenance
enhanccd flexibility, and simplifed ty, increased testability, 2 AOP addresses
concerns are
functionalities that cut
caching,
authentication, and
DI separates the creation and 3 Cross-cutting such as logging,
interfaces.
consumpt
for code to be organized intosmaller
unitsiowith
n of cleardependencies, allowing modules or
transaction
components,
management.
approach to
separate and
manage these
responsibilities and
4 AOP provides
Concerns.
amodular
L121(MCA-Sem-3)
Web Technology Spring
5 Thishelps in promoting code modularity,,reusability, and
6. In the Springframework, AOP is seamlessly
robust support for aspect-oriented programming.
4integrated
-1 1(MmaCA-intaiSneabmil-tay.
and
Request:Request scope is specific to web
newinstance
only
applications.
It creates a
of a bean for each HTTP request. The bean is available
withinthe scope of that request and is destroyed once the request
1. AOP in Spring is primarily based on proxy-based AOP
andiisi implemented
provides iscompleted.
:Session scope issalso applicable to web applications. It creates
using runtime proxies. 4 Session:
instance of a bean for each user session. The bean is destroyed
Key concepts in AOP: a new ends.
1. when the session
Aspect:An aspect is a modular unit of scope but applies
Clobal Session :This scope is similar to the Session single
encapsulates a concern, such as logging cross-cutting
2 Join point : Ajoin point
a program, typically represents a
or security.
specific point
functionality
in
that
the execution at
toapplications that use a global session. It creates a
abean per global session andis available
instance of
across multiple HTTP sessions.
corresponding to method invocations define their own
handling. or Custom Scopes : Spring also allows developers to scopes tailored to specific
3 Pointcut : Apointcut is a predicate that exception custom scopes. This gives flexibility to create
requirements.
specific points in the code where advice selectsjoin points, defining the
is the code that runs at a should applied. in Spring? How is it different
4. be
Advice: Advice Que 4.13. |What is the Singleton scope
the behavior particular join point. It represents
associated with a cross-cutling
5. Aspect configuration : Aspect concern. from other scopes ?
applied to the target objects and coniguration defines how the aspectis Answer
executed. specifies the pointcuts and advice to be is set to
container creates exactly
singleton, the Spring loC definition.
1. Ifa scope
object defined by that bean
one instance of the
such singleton beans, and all
2 This single
instance is stored in a cache of return the
references for that named bean
Bean Scopes : Singleton, PART subsequent requests and
Prototype, Request, Session, cached object.
Answer Answer
1. Ifthe scope is declared prototype,then spring IOC Session scope in Spring:
a new instance of that bean every time a
request container
is will\
Create , In Spring, the session scope is one of the bean scopes available for
specific bean. made for that managing object instances.
Arequest can be made to the bean instance
either The session scope defines that a single instance of abean is created
using getBean() method or by XML for
secondary type.
3. Generally, we use the
Dependency prograInjmmatectiiocaln lyof 2
3
and associated with an HTTP session.
The bean remains active throughout the lifespan of that specific
while the singleton scopeprototype scope for all beans
is used for the stateless that are
session and is destroyed when the session ends or expires.
beans. stateful. 4 The session scope is particularly relevant in web applications, where
Que 4.15.Explain the Request user sessions are maintained.
web applications ? scope in Spring. How is it related to beans that store and
5. By using the session scope, you can create related to a
manage session-specific data or perform operations
Answer particular user session.
A Request scope in is different from other scopes,
1 In Spring, the Spring: B. Difference:The Session scope in Spring scopes, in the following ways:
request scope is one of the bean such as Singleton, Prototype, and Request
managing object instances. scopes available for 1. Scope Duration : The
Session scope lasts longer than the Request
The request scope
defines that a new instance of a scope but shorter than the Singleton scope.
for each
individual scope, each user session
3 HTTP request made to a web bean is created 2 Instance Association : In the Session In contrast, Singleton
The bean remains of a bean.
active application. will have its own unique instance application,
B.
throughout processing
request and is then destroyed once thethe of that specific scope has a single shared
instance across the entire
instance per request or
creates a new
Request scope request is while Prototype scope
1. relation to web
The request scope is applications completed.
: dependency injection.
the Session scope effectively,
Spring
2. applications, where eachprimarily relevant
user request is
in the context of web 3 Scoped Proxy:To manage mechanism. In contrast, other scopes like
When abean is processed uses a scoped proxy require scoped proxies.
user request scopeda as "request in Spring, independently.
receives separate instance of thatit ensures that each
state and behavior
Singleton and Prototype do not
Context: The Session scope
is specific to web
bean, isolating the Web Application relevant when using Spring's web-related
3.
The request scope isspecific to that request. applications and is Prototype are
like Singleton and limited to web
specific data or commonly used for beans that hold components. Other scopes
Spring applications, not
4
For example, inperform
a web operations related to a specifc HTTP request applicable in various types of
5
handles user requests. apphcation, you may have a controllerrequest.
Within that controller, you that
environments.
Applicationscope (Singleton
scope) work
does the
responsible for might have a Que 4.17. How would you use it ?
6 By using the validating and /rocessing the request-scoped bean what scenarios
request scope, you ensure thatincoming regquest data. in Spring ? In
handled by a separate
instance of that bean, each user request is
between concurrent requests. Answer
Application scope in Spring : only one instance ofa
Oue 4.16. What is preventing interference A. Working ofInstance : In the Application scope,the application. Any
the Session Single shared throughout instance.
from other scopes ? scope in Spring? How is it 1.
bean is created
and
that bean will
receive the same
across the
different subsequent requests for
State : Since the same
instance is shared
state of the bean will e
2
Shared changes made to the
application, any
Web Technology 4-181 (MCA-Bem-3) CI61 (MCA-8em-3)
reflected across all components that use that bean. This
Spring
advantageous when you want to maintain a shared state orcan be
1. Connection
sends a Establishment:
WebSocket With WebSocket in Spring, client
data among dilferent parts of the application. share handshake
the request, upgrades the
request. The server, upon receiving
3 Thread Safety : When using the. Application scope, it'sa
connection to the WebSocket protocol,
enabling bi-directional communication
important
to conaider thread safety. Il multiple threads access andI modifythe
ahared bean instance concurrently, you need to
8erver. between the client and
Message Exchange : Once the
synchronization or use thread-safe techniques toensure
preventproper
race established, the client and server canWebSocket connection ís
condition and data inconsistencies. time. exchange messages in real
B. Scenarlos : Here are some common scenarios where you would uee
the Application scope:
3. Event-Driven Model :
driven model, where theWebSocket
in Spring follows an event
server and client can react t events
L. Configuration Beans Beans that provide application-wide asynchronously.
configuration settings or manage shared resources can be sconed 4 Broadcasting and Pub/Sub : WebSocket in Spring supports
as Application beans. For example, database connection poola. broadcasting messages to multiple clients or implementing pub/sub
configuration managers, or caching components can be scoped as communication patterns. This enables real-time updates and
singletons to ensure consistent behavior and resource sharing. notifications to be efficiently distributed among nultiple clients.
2 Stateful Beans : Beans that maíntain mutable state or manage 5 Integration with 8pring Components : WebSocket in Spring
application-wide data can be Bcoped as singletons. This allows can be seamlessly integrated with other Spring components. This
different components to access and modify the shared state, allows you to apply security measures, authenticate users, and
promoting data consiténcy and efficient resource utilization. leverage existing Spring infrastructure.
Performanoe
instances of a Optimization
: In some cases, creating multiple
particular bean might be expensive in terms of Que 4.19. How does Spring support WebSocket communícation ?
memory or resource uAge. By
ensure that a single instanceusing the Application scope, you can
is reused, reductng overhead and Explain the relevant components.
improving perforuance. Answer
Spring provides support for WebSocket communication through the Spring
PART-6 WebSocket module. This module integrates WebSocket functionality into
WebSocket. the Spring framework, making it easy to develop WebSocket-enabled
applications,
provided
Que 4.18. What is Relevant components : Following are the relevant components
Web8oclket in 8pring ? How does it
facilitate by Spring for WebSocket communication :
real-time communicatlon ? 1 WebSocketHandler:The WebSocketHandler interface is implemented
messages and events. It defines
Answer by a Spring bean to handle WebSocket handleTransportError() that
methods such as handleMessage) aad
A Web8ocket in Spring : ebSocket messages and handle
allow you to process incoming V
1
WebSocket is a communication
WebSocket-related errors.
object represents a
communication
It channels over aprotocol that provides
single TCP connection.full-duplex 2 WebSocketSession : The WebSocketSession
client and the server. It provides methods to send
2. enables real-time and connection between a
retrieve attributes, and get
information
client and a server. bidirectional communication between a messages, close the session,
3. In the context of Spring, about the session. interface is used
applications that faccilitate WebSocket support The WebSocketConfigurer
WebSocket Configurer:handling implementing this
real-time allows you to build 3 in Spring. By
instances and set e
B.
and servers,
Real-time communication : communication between clients to configure WebSocket
register WebSocketHandler
interface, you can
facilitates real-time commnunication:Here's how WebSocket-related settings.
WebSocket in Spring
Web Technology L18I(MCA-Sem-3)
Annotations.
PART-7
Autowiring. Que 4.21. Explain the concept of annotations in Spring. How are
Que 4.20. What is they used in bean configuration ?
bean configuration?
Auto-wiring in Spring ? How does it simplify OR
used for spring
Classify all the annotations those are exciusively
Answer AKTU2022-23, Marks 10
boot applications.
A
Auto-wiring
1.
in Spring :
Auto-wiring in Spring is a feature that Answer
dependencies
configuration.
between beans without automatically
the need for resolves
explicit
Spring boot annotations :
form of metadata that provides
data about
annotation is a
2. It simplifies bean 1 Spring boot
based on their types, configuration bytheautomatically connecting beans a program. information about a
provide supplemental develop.
B. eliminating need for manual wiring. 2 Annotations are used to application that we
Simplification of
simplifies the processbean
: configuration : Here's how Auto-wiring program. It is not a part of
direct
the
the code they
effect on the operation of program.
have a
1. 8. It does not the action of the compiled
Dependency
explicitlythedefineResolution :
and wire With auto-wiring, you don't need to
annotate. It does not change
annotations :
Instead, Spring IoC
the dependencies of a bean.
dependencies in XML
configuration
(Inversion of Control) container files. Core spring framework
@Required : It applies to the bean configuration time
that the
setter method. It indicateswith the
analyzes L. populated at
annotated bean must be else it throws an exception
2
Automatic Injection :Once the
Spring required property;
the dependent dependencies
container automatically injects the
are identified, the BeanInitializationException. annotation-based auto-wiring by
the dependencies.bean. You corresponding
don't have to write beans
into
explicit code to wire 2. @Autowired : Spring provides
annotation. It is used to autowire spring bean
constructor. When we use
providing @Autowired
Reduction in
need for manualConiguration methods, instance
variable, and
auto-wires the bean by
code. wiring and Code : Auto-wiring
reduces the amount ofeliminates the
on setter annotation, the spring container
@Autowired annotated
configuration matching data-type.
@Configuration:Itis aclass-level
annotation. The class of bean
Spring Containers
as a source
@Configuration used by
with
definitions.
Web Technology
4-19I (MCA-Sem3) -90I(MCA-Sem-3) Spring
4 ComponentSean : It is used when we want to
beans. It is used with the annotation scan a package for conceptin the Spring framework and represents the building
@Configuration.
specify the base packages to scan for Spring Components. We can also
It is acore application.
blocks of an
5 @Bean : It is a method-level annotation. It is Spring are instantiated, assembled, and managed by the
an Beans in
XML<bean>tag. It tells the method to produce a bean to of alternative
be container.
by spring container. managed Beans provide various benefits such as dependency injection, aspect
oriented programming, and modularity.
PART-9
Controlling bean life cycle :
Life Cycle Call Backs. of several phases, including
1 The lifecycle of a bean in Spring consistsand destruction.
bean instantiation, initialization, usage,
control and custonmize the lifecycle of
Que 4.22. Can we call a Java class
with 2 Spring provides mechanisnms to
annotations as a PO.JO beans.
Spring:
class or not ?
AKTU 2021-22, Marks 10 1 Here are the main ways to control the bean lifecvcle in
Answer A Bean instantiation :
be instantiated using
Constructor injection: Beans caninjected
1. Technically, you can call a Java class with 1. via constructor
Old Java Object) class, but it annotations a POJO (Plain constructors and dependencies can be
annotations. depends on the purpose usage of the
and parameters.
instantiated using a default
2. The term POJO" generally
refers to a 2 Setter injection : Beans can be be injected using setter
dependencies can
encapsulates data and provides getter and simple Java class that constructor and
and modifying that data. setter methods for accessing methods.
3 It is alightweight class that
or libraries. does not depend on any B. Initialization:
@PostConstruct: Beans can
4. external frameworks InitializingBean and interface or use the
Annotations, onto the other hand, are a way to add 1.
implement the
InitializingBean logic.
5 information Java code elements,such as classes, metadata or additional @PostConstruct annotation to define initialization
Annotations can be used for a methods, or fields.
variety of purposes, XML configuration allows
specifying
6 configuration, documentation,
If the or runtime
used in a Java class arebehavior
including 2. XML Configuration :using the <init-method> attribute.
initialization methods
annotations
configuration modification.
purely for
7
However, if thepurposes, ther you can still consider the classmetadata or C. Usage : Beans can define
methods that perform
or
dependencies annotations used in the class as a POJO.
introduce specific behavior Bean methods :
functionality. These methods
can be
class may be tied to a particular framework specific tasks or provide
It may have considered more than just a simple or library, then the
initialized.
bean is
8 called after the
additional
those annotations. or POJO.
responsiblities dependencies implement
associated with D. Destruction : @PreDestroy:Beans can Destroy
Que 4.23. What is Bean in DisposableBean and or use the @Pre
1. DisposableBean interface
Spring ? How Bean life can be
the
annotation to define
cleanup logic.
specifying
controlled in Spring ? cycle configuration allows
Configuration :XML <destroy-method> attribute.
Answer |AKTU2021-22, Marks l0 2 XML
destruction methods
using the
callbacks in
Bean:
different types of life cycle
1 In Spring, a bean is an What are the
object that is Que 4.24.
(Inversion of Control) container. each one.
managed by the Spring loC Spring ? Explain
-221(MCA-Sem-3)
Web Technology
4-21I (MCA-Sem-3) Spring
Answer Example :
el-- Bean definition in XML ->
Spring bean factory controlsthe creation and destruction of cbean id="myBean" class="com.example. MyBean'>
some custom code, the bean factory provides the callback beans. To execute <property name-="name" value="John>
can becategorized as follow:
Initialization Callbacks :
methods,
which </bean>
Java-based Configuration : Java-based configuration, also known
2
oPostConstruct Annotation : This as JavaConfig, allows you to configure beans using Java classes. You
method that should be executed after aannotation
bean
is placed on
use annotations and J.va code to define beans, dependencies, and
and its dependencies have been injected. It ishas been instantiated configuration.
perform initialization tasks. commonly usedto Example:
C u m
Callback:Ifinitialization
5-7I to 5-81
Initialization
with the abean defines an Part-6 : Spring Boot
Runners
after all @PostConstruct'
use. Thisdependenci annotation,
and Spring
initialization method 6-8I to 5-9I
Destruction
with the Callback :If bean appl
a ication's life cycle. Mapping, Request
Body ,.... 5-12E
to 5-13E
the destruction
edest
callb ruct
ackS io
aren
perform cleanup operations, invoked phase for all beans.context
to
is closed,
It ensures that
Part-12: Build Web
release resources and
5-1 I (MCA-Sem-3)
B-21 (MCA Sem 3)
WebTechnology
Spring Bot Embedded.servers: Spring boot includes sembedded
5-3I (MCA-Sem-3)
PART-1 (for example, Tomcat) that can be run as part of the servlet containers
application.
Spring Boot :Spring Boot Configurations. Dependency management : Spring boot incorporates Spring's
dependency management features, allowing easy management and
resolution of dependencies.
Que 5.1. What is Spring Boot ? Write down the Actuator : Spring boot actuator provides built-in endpoints and
goals of monitoring capabilities for managing and monitoring applications.
Boot.
Answer
Spring Disadvantages of using spring boot :
Learning curve : Spring boot is built on top of the spring framework.
1. Spring Boot is a projectt that is built on the For developers new to spring, there is a learning curve involved.
top of the Can be inflexible: Spring boot uses an opinionated approach. This
2. It provides an easier
and faster way to set up,
configure, and run botl
Spring framework. makes it less flexible.
simple and web-based application. incorporates embedded
3 It is a Spring module that 3 Increased memory usage:As spring boot consume
provides the RAD (Rapid Application
Development) feature to the Spring servers, actuator, and other features, it may more memory.
4 It is used to create a framework. 4 Potential overengineering:For smallapplications, using spring
stand-alone Spring-based application that you can
just run because it needs boot may introduce unnecessary
complexity and overhead.
5. Spring Boot is the minimal Spring configuration. 6. Limited control : With spring boot's auto-configuration, developers
Servers. combination of Spring Framework and Embedded have less control over the configuration
details.
6 In Spring Boot, there is (Spring
no requirement for and install Spring tool suite
Que 5.3. How to download
7 (deployment
It uses
descriptor). XML configuration Tools 4 for Eclipse) IDE?
means itconvention over configuration software design paradigm that
8 We can decreases the efort of the
use Spring STS IDE or developer. Answer
Spring tool suite:
Java applications. Spring Initializr todevelop Steps to download and install in
Goals of Spring Boot Tools 4, for the Eclipse section
Spring
Boot : official website and in Spring
Step 1: Go to your OS.
according to
development, unit test, and The main goal of Spring Boot is to your corresponding file
order to download.choose button aJar file will be downloaded to your local
1 integration
Provides opinionated development test time. reduce on the
Step 2:After clickingfolder Jar file to that folder. And double
2.
Avoids defining more and move this
3. approach.
annotation configuration.
Avoids writing lots of import system. Now create a pop-up window will appear.
Jar file. A ereate. Now open the
click on that Unpacking, a new folderwill
4
Avoids XML configuration. statements. Step 3 :After successfully
file.
Que 52. folder. SpringToolSuite4 ApplicationBrowse
What are the folder now click on the clicking on the
Step 4: In this directory as workspace by
spring boot ? advantages and disadyantages of using your
Step 5: Now select on the Launch button. And youare
done.
button and then click project in Spring
Answer AKTU2021-22, Marks 10 to create and setup Spring Boot
Que 5.4. How
Advantages
Rapid
of using spring boot : tool suite ?
application
2.
configuration
development
configure a capabilities, allowing:Spring provides
ConventionSpring-based application.developers
over
boot a set ofauto-
to quickly set up and
Answer
Steps to create
Spring Boot project
Spring Tool Suite
:
and setup (Spring Tools 4 for Eclipse IDE
Project
Step 1: Install File > New >Spring Starterand further click on the Nas
of convention over
configuration, making conf
confiiggururaattiioon.n ThisSpringreducesBoot thefollows the
:
principle Step 2: Go to the
in pop-up
window as follows
straightforward button :
84I (MCA-Sem-3) Web Technology 5-5I (MCA-Sem-3)
<ar<vertifsaioctn>lld>s.5.p8.rRinELEASE</
<parent>
We should specify the
g-boot-starvterers-ipoarn>ent</artifactId> Answer
In a Spring Boot application,
the code is typically structured in following
structure organizes
dependency. version number for Spring Boot
Then for other certain conventions and best practices. The recommended
typical structure
the Spring Boot starter dependencies, we do notParent Starter
version number. the code in a modular and
maintainable way. Following is a
need to specify
Observe the code given below: application:
<dependencies> for a Spring Boot
Main Application
with a main class
Class : The application startsserves as the entry
<dependency> L
annotated with
@SpringBootApplication. This class environment.
and initializes the Spring
Boot
<a<grrtoifuapcltdld>>osrpgr.sinpgri-nbgofrat-msteawrteorr-kw.beob<t/<a/rgtirfoaucptIldd>>
point of the application responsible for handling
These classes are
2 Controller Classes : responses. They are
returning appropriate
ddependency>
<Jdependencies>
ncoming requests and @Rest Controller or @Controller.
Ypically annotated with the business logic
of the
Gradle dependency : Classes : Service classes contain often annotated
serice complex operations and are
We can application. They handle
file. Weimport the Spring Boot
do not need Starters dependencies directly into with @Service. the database or
classes interact with storage, and
Spring Boot
Gradle. Observe the code start Tepository/DAO Classes: These
given below: Parent dependency likebuild. gradletor 4 for data retrieval,
buildseript | They are responsible @Repository or
exxt
Maven Other data sources. are typically annotated with
manipulation. Thev
represent the data
@Component. Classes : Model or entity classes and relationships
)
springBootVersion =1.5.8.RELEASE
repositories
5 Model/Entity
Structure ofthe
application. They define the
in the application.
structure
classes provide
additional
of the objects usedClasses : Configuration the application. They can
mavenCentral() 6, Coniguration customization options for configuration, etc. These
configuration and configuration,security
database @Configuration.
dependencies ( nclude beans, annotated with helper methods
and utility
They
classes are often classes contain application.
Utility parts ofthe
7. Utility Classes: used across different code snippets.
compilet'org.springframework.bo t:spring-b0ot-sarte-web')
) in a
PART-6
SpringBootRunners.
5-8I(MCA-Sem-3) 5-9I (MCA-Sem-3)
Web Technology
Spring Bo,
Que 59. Describe application runner and : Log Level : This provides the information on what level of
command]line information the log is of. It will be one out of the 7 options we will
Answer
runner. see now, i.e., TRACE, DEBUG, INF0, WARN, ERROR. FATAL Or
1 OFF.
SpringBoot provides two runner interfaces, ii. Process ID :This provides the information of the process ID
on
ApplicationRunner,
CommandLineRunner. Being Functional Interfaces, both the mun application is running on.
have a single functional method, run(). which the spring boot
the next part of the
2 When we implement one of these iv. Separator: This is a separator which signifies
run) method after it starts the runners, Spring Boot invokes ite log.
3
context and before the application
That me ans we can use Spring Boot starts ThreadName:This is enclosed within a square([|) brackets and
V.
logging thread or
CommandLineRunner or mostly contains the thread within which the
ApplicationRunner to execute a piece of code when
Application or to create a Spring Boot launching an element is present.
non-web application. penultimate element that contains the
4. Overall, both vi. Logger Namne :This is the
CommandLineRunner
and we can use them to do and
ApplicationRunner are similar,
exact same things.
source class name.
element contains the log message,
5. The only
difference between the two interfaces is the vii. Log Message : Finally, this application and helps
followed in the
run) method. The run() signature of the which explains the methods application.
method in the cause if an error pops up in the
6.
the application or program
However, the run() method argument
CommandLineRunner
as an array of
String.
receives us tracing back to the root
in
arguments wrapped in an ApplicationRunner receives the program PART-8
Que h.J2,Mow to bulld Henttul web aurvleon ln I|PUT rouest to uplate a book
Aprlng Boot?
WPutMupping("/idl")
Anowor publie RosponseEntity«Buring uplateBook(@PathVariable Long
Por bulldingu lt#Thl Wab Forvleon, wa vul o ndd id, wtoquostBody Book updatodBook)
Walb dependoney into the build eofiguratjon Nlo. the lprlng Boot tartar | Vind the book with the givon ID
or Mavon usur, un4 thu followlng code to nld Optionnl-Books optionalBook -books.stroam)
pom ml le (h below depondeney in nltor(book > book,getld0.oqualsid)
dependony indlirat),
*Kroupld>orgwpringlrNmewor.
arlifwtldnprlng bootelgroupld
boxt atarlor-wehe/urtifetld
if(optionalBook,islresent)) |
Book book = optionallfook get);
-llupondeney
Vor Oradle unor, /Updatu the book propertios
lise thu pollowing vode w add tho book set'1'itleluplntedBook gotTitle));
bulld.grle hle, below dependony ln book,sotAuthouplntedBook.gotAuthor0;
compilal'owg updatad succossfiully."D):
aprluglrnmawork.boob:npring
Que h.Ja.Urunte altKWTul
bol atartar web') retun osponsentity. ok("Book
JookControllhmndl
ontaln methoda for er elalnHKg o
handlute ETl ondpoluts, It wll
DLGTW and PT 'requoata.
5-12 I (MCA-Sem-3) Spring Boot Web Technology
5-13 I (MCA-Sem-3)
Configure the main application class. The class-level
7.
a controller. annotation maps a specific request path or pattern onto
@SpringBootApplication
public class RestfulApplication ( 4 We can then apply
additional
public static void main(Stringllargs) mappings more specific to handlermethod-level
methods. annotations
to make
SpringApplication.run(RestfulApplication.class, args); 5 The @RequestMapping annotation is
access the REST Endpoints. used to define the Request URI to
6 We can define
Request method to consume and produce object.
7. The default request
8 Run the application. method is GET.
@RequestMapping(value =/products")
public ResponseEntity<Object> getProducts0 ()
PART-9
Rest Controller.
Que 5.16. Define the terms:
1. Request Body 2. Path Variable
3. Request Parameter
Que 5.14. What is rest controller ?
Answer
Answer 1. Request body : The @RequestBody anno kation is used to define the
1. RestController is used for making restful web services with the help of request body content type.
the @Rest Controller annotation. public Response Entity<Object> createProduct(@Request Body Product
product) (
2 This annotation is used at the class level and allows the class to handle
the requests made by the client. 2. Path Variable:
3 The RestController allows to handle all REST APIs such as GET,POST, The @PathVariable annotation is used to define the custom or
Delete, PUT requests. dynamic request
URI. The Path variable in request URI is defined as curly braces () as given
4 It serves JSON, XML and custom response. below :
5. Itssyntaxis as follows: public ResponseEntity<Object> updateProduct(@PathVariable("id") String
@Rest Controller id) {
public class ProductServiceController
3 Request Parameter:
The @RequestParam annotation is used to read the request parameters
from the Request URIL. By default, it is arequired parameter. We can also set
PART-10 default value for request parameters as :
Request Mapping, Request Body public ResponseEntity<Object> getProduct
@RequestParam(value ="name", required =false, defaultValue ="honey")
Path Variable, Request Parameter.
String name)
Answer
1. application.properties
Testing : Write unit tests andor application.yml.
methods using testing frameworksintegration
configuration
tests for your
GET API: The default HTTP request method is GET. This mnethod dogs e 8. Run the like
JUnit and Spring Test. controller
require any Request Body. You can send request parameters and path IDE or theapplication : Run
command line. your Spring Boot application using
9. your
variables to define the custom or dynamic URL.
POST API: The HTTP POST request is used to create a resource, This Deployment
tool. You can
:Build an
executable JAR or WAR file using
deploy this file to your build
method contains the Request Body. We can send request parameters and servers or cloud platforms. various environments, including traditional
path variables to define the custom or dynamic URL.
PUT API:The HTTP PUT request is used to Que 5.19. Explain the role of
This method contains a Request Body. We can update the existing resource.
Spring Boot web applications. templates
send request parameters and
and view resolvers in
path variables to define the custom or dynamic URL.
DELETE API : The HTTP Delete request is used to delete the Answer
resource. This method does not contain any Request Body. We can existing
request parameters and path variables to define the custom or dynamicsend Role of templates in Spring Boot web
URL.
1
Templates are files that contain a mix ofapplications:
static content and
for dynamicdata. placeholders
2. They are used to generate dynamic HTML
PART-12| client's web browser. content that is sent to the
3.
Build Web Applications. Templates allow developers to create reusable and consistent
for displaying data. layouts
Que 5.18. How can you use Spring Boot to 4 In Spring Boot web applications,
build web applications ? templates, replacing placeholders withtemplate engines process these
actual data values.
5 Common template engines
Answer used in Spring Boot applications include
Following is a general guide on how to use Spring Boot to build Thymeleaf, FreeMarker, and JSP (JavaServer Pages).
applications : web 6. Each of these template engines has its syntax and features, but
serve the same purpose of dynamically generating HTML they all
1. Setup project : Start by creating a new Spring Boot Role of view resolvers in Spring Boot web applications :content.
either Spring Initializr or your preferred project using
environment (IDE). integrated development 1. A view resolver is responsible for determiniig which template to use for
2.
Dependencies : In your project's build configuration include the rendering a specificview (web page) and then invoking the template
necessary dependencies for building web applications. Common engine to process the template and generate the final HTML output.
dependencies include spring-boot-starter-web for basic web functionality, 2 It essentially resolves the logical view name to the actual template file.
and additional dependencies for templating 3. In a Spring Boot application, you corigure a view resolver to handle the
3 Create controllers : Create classes engines and database access. mapping between logical view narmes and the corresponding template
annotatcd with @Controller or
@RestController to handle incoming HTTP requests. Use
files.
@RequestMapping and related annotations todefine
URLS and controller mappings betwcen 4 This enables you to work with logical view names in your controller
methods rather than specifying the exact template paths.
methods.
4 View templates : If your application requires 5 Spring Boot provides default view resolver configurations, making it
content, include the corresponding Spring Boot starterrendering dynamic easier to get started.
create template files in the designated directory, and use dependency,
engine's syntax to generate dynamic content. the template
5. Static resources: Place static resources such as CSS,
images in the src/main/resources/static directory. SpringJavaScript, and
Boot will serve
these re sources directly without requiring explicit cont roller mappings.
sQ-14 I (MCA-Sem-3)
2 Marks Questions
Web Technology SQ-13 I (MCA-Sem-3) B. Declarative support 6. Portable
4.5. What are the
different
Ans. ASpring application, components of a Spring application?
4
UNIT
(2 Marks Questions)
Spring
1. Interface : It
2. Bean class: It
3.
4.
functions etc.
generally consists of following components:
defines the functions.
contains properties, its setter and getter
Spring Aspect Oriented Programming (A0P) :
functionality of cross-cutting concerns.
Bean Configuration
methods,
Provides the
File : Contains the information of
and how to configure them. classes
5. User program : It uses the
function.
4.1. What is a Spring framework? 4.6. How many types of IOC
Ans. Types of I0C containers containers
are there in spring ?
in
1. Spring is a lightweight framework, It can be tho ught of as a 1. BeanFactory: BeanFactory isspring :
like factory class that contains a
a
framework of frameworks because it provides support to various collection of beans. It instantiates the bean whenever
clients. asked for by
frameworks such as Struts, Hibernate, Tapestry, EJB, JSF, etc. 2.
2. The framework can be defined as a structure where we find
solution ApplicationContext
on top of the
: The
ApplicationContext interface is built
of the various technical problems. BeanFactory interface. It provides some extra
functionality on top BeanFactory.
4.2. What are the different features of Spring framework ?
AKS Following are some of the major features of Spring framework: 4.7. What is AOP ?
1 Inversion of control (IOC):The objects give their dependencies AKTU 2021-22, Marks 02
instead of creating or lookingfor dependent objects. This is called Ane. AOP stands for aspect-oriented
programming. It is a
paradigm and methodology that aims to modularize programming
Inversion OF Control. cross-cutting
2 Aspect oriented Programming (AOP) : Aspect oriented concerns in software systems. It helps to address common software
engineering challenges related to cross-cutting concerns, such as
programming in Spring supports cohesive development by code duplication, tangled dependencies, and reduced modularity.
separating application business logic from system services.
3. Cont.ainer: Spring Framework creates and manages the life cycle
and configuration of the application objects. 4.8. Explain the importanee of IoC in spring.
AKTU2022-23, Marks 02
43, In how many ways can dependency injection be done ? Ans. loCis fundamental to the Spring frameworkand plays avital role
ks1. Constructor
Ingeneral, dependency
injection
injection canbe done in three ways, namely : in promoting loose coupling, configurability, testability, modular
development, and integration with other frameworks. It simplifes
2. Setter injection appication development and maintenance, enhances code quality.
3. Interface injection and enables building flexible and sralable applications.
In Spring framework, only constructor and setter injections are
used. A0 Differentiate between bean factory and application context.
AKTU 2022-23, Marks 02
44. List the advantages of Spring Framework.
OR
Discuss advantages of spring framework.
|AKTU 2021-22, Marks 02
Ans Ad vantages of spring framework :
1 Light weight 2. Flexible
3. Loose coupling 4. Powerful abstraction
Web Technology sQ-16 I(MCA-Sem-3)
sQ-15 I (MCA-Sem-3) 2 Marks Questions
Ans. Following are some of the
possibilityand:limitations
1.
S.No. Aspect Bean factory Overriding with auto wiring:
You can always
1.
Instantiation Lazy initialization Application context
:Eager
using
<constructor-arg>
autowiring. <property> specify dependencies
settings which will override
of beans Beans initialization
are instantiated Beans are 9
Primitive data
when requested. instantiatod
at application startup. and Classes can'ttype:Simple
be autowired.properties such as primitives, Strings
2
3. Confusing nature :Always prefer
Bean XML-based or XML-based, using explicit wiring because
autowiring is less precise.
configuration
and wiring
programmatically programmatically
configured. configured, or A14. What do you
|annotation-based understand by
Ans. @Required is applied to bean@Required annotation 2
configuration. property setter methods. This
annotation simply indicates that the
affected
4.10. Explain Spring Beans?
be populated at the
configuration ortime with thebean
Droperty value in a bean helpproperty must
of an explicit
Ans definition with
bean property has not been populated, the autowiring. Ifthe afected
1 They are the objects that form the container will throw
2. Beans are managed by the Springbackbone BeanlnitializationException.
of the user's application
3. They are instantiated,
loC container.
configured, wired and
managed by a Spring 4.15. What do you understand by
LoC container. @Qualifier annotation ?
Ans, When you create more than one bean
4. Beans are created with the wire only one of them with a propertyofyou
the same type and want to
supply to the container. configuration metadata that the users annotation along with @Autowired to remove can use the @Qualifier
specifying which exact bean should be wired. the ambiguity by
MetaData IoC Container
Beans 4.16. What is Spring configuration file ?
Ans. Spring configuration file is an XML file. This file
contains the classes
4.11. How many bean scopes are information and describes how these classes are configured and
Ans: The Spring framework supportssupported
five
by Spring ? introduced to each other.
L Singleton : This provides scopes. They are:
scope for the bean definition to single 4.17. What is Spring IoC container?
instance per Spring IoC container. Ans. The Spring IoC creates the objects, wire them together,
2. Prototype: This provides scope for a configure
any number of object instances. single bean definition to have them, and manage their complete lifecycle from creation till
3. Request: This provides scope for a destruction. The Spring container uses dependency injection (DI)
bean definition to an HTTP to manage the components that make up an application.
request.
4. Session : This provides scope
for a bean definition to an HTTP.
session.
5. Global-session : This provides scope for a bean definition to an
Global HTTP-session.
4.12. Define Bean wiring.
Ans When beans are combined together
it's called wiring or bean wiring. Thewithin the Spring container,
know what beans are needed and howSpring the
container needs to
dependency injection to tie the beans together,container should use
while wiring beans.
4.13, What are the limitations with auto
wiring?
Web Technology SQ-17 I(MCA-Sem-3) SQ-18 I (MCA-Sem-3)
2 Marks Questions
Ans.
5
UNIT Spring Boot
(2 MarksQuestions)
S. No. Aspect
1
2.
Framework
purpose
Spring
Comprehensive
enterprise application| and
framework.
Spring Boot
Simplified development
deployment of
spring applications.
Configuration Requires manual| Convention-over
3
configuration. configuration approach.
Dependency Developers need to| Automatic dependency
5.1. What is a Spring boot ? management manage dependencies management.
An Spring Boot provides a good platform for Java developers to manually.
astand-alone and production-grade spring appication that develon
you can 5.6. What are the
features of Spring Boot Actuator ?
just run. You can get started with minimum configurations without Ans. There are three main features
the need for an entire Spring configuration setup. 1. Endpoints of Spring Boot Actuator:
2. Metrics
52. What are the advantages of Spring 3. Audit
Ana Spring Boot offers the folowing boot ?
advantages to its developers:
1. Easy to understand and develop spring 5.7.
applications. Define metrics in
2. Increases productivity. Ans. Spring Boot Actuatorspring boot.
3. Reduces the development time. with the micrometer.provides dimensional
The micrometer metrics by integrating
is integrated into
Boot. It is the instrumentation Spring
5.3.
AnE
What are the goals of Spring boot ? application metrics from Spring. It library powering the delivery of
provides vendor-neutral interfaces
Spring Boot is designed with the following goals: for timers, gauges, counters, distribution
1. To avoid complex XML timers with a dimensional data model. summaries, and long task
2. To develop a productionconfiguration in Spring.
ready Spring applications in an easier way.
3. To reduce the 5.8. What are the
development time and run the application advantages RESTful web services ?
independently.
4 Offer an easier way of
Ans. Advantages of
RESTful web services:
getting started with 1. RESTful web services are
the application. platform-independent.
2. It can be written in any programming language and can be executed
54. What are the benefits of on any platfor1n.
AKE Benefits of using spring using
boot :
spring boot ? 3. It provides different data format like JSON, text, HTML, and XML.
1. It provides a flexible way to configure Java Beans, XML 4. Itis fast in comparison to SOAP because there isno strict specification
configurations, and Database Transactions.
2. It
like SOAP.
provides a
powerful batch processing and manages REST
endpoints. 5.9. Explain Spring boot logging.
3. In Spring Boot,
everything is auto configured; no manual
configurations are needed.
Ans. Spring boot logging is defined as a framework that enables
developers to trace out errors that might occur in the running of
4. It offers
annotation-based spring application.
5. Eases dependency
the application.
6. It includes Embeddedmanagement.
Servlet Container. 5.10. Define Spring Boot annotations.
55. Difference between Spring and Spring boot. An: Spring Boot Annotations is a form of metadata that provides data
about a program. In other words, annotations are used to provide
|AKTU 2021-22, 2022-23; Marks 02 supplemental information about a program. It is not a part of the
application that we develop. It does not have a direct effect on the
SP-1I(MCA-Sem-3)
Web Technology Web Technology
SQ-19 I (MCA-Sem-3) MCA
operation of the code they annotate. It does not THEORY
of the compiled change the t: SEMESTER
program. (SEM. III) ODD
EXAMNATION, 2021-22
5.11. What are the effects of
running spring boot
application WEB TECHNOLOGY
Java application ?
Ans Runninga spring boot AKTU 2021-22, Marks 02 Max. Marks: 100
convenienceas during application as a Java application provides
development
deployment a standalone and testing, simplifies Time :3 Hours
data; then
embedded web server. application, and allows utilizing the If yourequire any
missing
Note: 1. Attempt all Sections.
5.12. choose suitably.
Discuss, can we call ajava class with
class or not ?
annotations as POJO SECTION A
Ans. Yes, a Java class with
AKTU 2022-23, Márks 02 (2x 10 = 20)
(Plain Old Java Object)annotations can still be considered a PO.Jo
Attempt all questions in brief. servlet ?
remain simple,
class. The key point is that the class should 1. advantages of using JSP over
framework-independent, and maintain its core a. What are the SQ-121, Unit-3,Two Marks
Questions.
purpose of encapsulating data and behavior. Ans Refer Q. 3.11, Page
adheres tothese principles, it can be regardedAsaslong as the class
a POJO, even if spring framework.
it uses annotations. b. Discuss advantage of
Unit-4, Two Marks Questions.
Ans. Refer Q. 4.4, Page SQ-13I,
Series application as
J u a
c. What are the effects of running spring boot
Java application ?
Ans. Refer Q. 5.11, Page SQ-19I, Unit-5, Two Marks Questions.
d. What is AOP?
Ans. Refer Q. 4.7, Page SQ-141, Unit-4, Two Marks Questions.
e. Is COM same as DCOM ? Comment on it.
Ans. Refer Q. 1.21, Page SQ-6I, Unit-1, Two Marks Questions.
f. Differentiate between web browser and web server.
Ans. Refer Q. 1.20, Page SQ 51, Unit-1, Two Marks Questions.
g. Compare CGI and JavaScript.
Ane. Refer Q. 2.15, Page SQ-91,Unit-2, Two Marks
Questions.
h. What is the
difference between forward and
tag in JSP ? sendRedirect
Ans. Refer Q. 3.12, Page SQ-121, Unit-3,
Two Marks Questions.
i. Explain main
characteristics of web team.
Ans: Refer Q. 1.18, Page SQ51, Unit-1, Two
Marks Questions.
j. Difference
Ans. between spring and spring boot.
Refer Q. 5.5, Page SQ-171,
Unit-5, Two Marks Questions.