AJ Ans
AJ Ans
Unit-5
1Draw the JSF request processing life cycle and briefly give the function of
each phase.
Ans:
f:validateLength
1
Validates the length of a string
f:validateLongRange
2
Validates the range of a numeric value
f:validateDoubleRange
3
Validates the range of a float value
f:validateRegex
4
Validates JSF component with a given regular expression
Custom Validator
5
Creates a custom validator
JSF Tag
<f:validateLength minimum = "5" maximum = "8" />
Tag Attributes
S.No Attribute & Description
minimum
1
A String with a minimum number of characters
maximum
2
A String with a maximum number of characters
JSF Tag
<f:validateLongRange minimum = "5" maximum = "200" />
Tag Attributes
S.No Attribute & Description
minimum
1
Minimum long value within an optional range
maximum
2
Maximum long value within an optional range
● When a user clicks a JSF button or link or changes any value in the text field, JSF
UI component fires an event, which will be handled by the application code.
● To handle such an event, an event handler is to be registered in the application
code.
● When a UI component checks that a user event has occurred, it creates an
● Then, Component fires the event, i.e., checks the list of listeners for that event
● JSF also provides system level event handlers, which can be used to perform
valueChangeListener
Value change events get fired when the user makes changes in input
components.
actionListener
Action events get fired when the user clicks a button or link component.
Application Events
PreDestroyApplicationEvent , PreRenderViewEvent.
Libraries provide additional features, components, and utilities that extend the
capabilities of JSF and help developers build robust and interactive web applications
more efficiently.
6 Write a short note on JSF Facelets. List the JSF facelets tags and explain any two.
Ans:
● JSF Facelets is a view technology that is used to create JavaServer Faces (JSF)
views.
● Facelets is based on XHTML, which is a markup language that is based on XML.
● Facelets pages are compiled into component trees, which are then rendered by
the JSF implementation.
Templates
<ui:insert>
1
<ui:define>
<ui:include>
<ui:composition>
Parameters
<ui:param>
Custom
3
We'll demonstrate how to create custom tags
Remove
4
We'll demonstrate capability to remove JSF code from generated HTML page
Custom tag:
JSF provides the developer with a powerful capability to define own custom tags,
Step Description
Create a tag library descriptor (.taglib.xml file) and declares the above
1b
custom tag in it.
Remove tag:
7 What is the JSF tag library? Explain any four html tag.
Ans:
● JSF framework provides a standard HTML tag library.
● Each tag will rendered into corresponding html output.
● Two types of JSF Tag library
○ <%@taglib uri=" http://java.sun.com/jsf/core" prefix=" f" %>
○ <%@taglib uri=" http://java.sun.com/jsf/html" prefix=" h" %>
● The JSF Expression Language (EL) is a powerful tool that can be used to access
and manipulate data in JSF applications.
● EL expressions are written in a simple syntax that is similar to Java.
● JSF provides a rich expression language.
● We can write normal operations using #{operation-expression} notation.
array.
● Provides easy access to predefined objects such as a request.
language.
Unit-7
The Spring MVC framework is a Java framework that is used to develop web
applications. It is built on the Model-View-Controller (MVC) design pattern, which
separates the application's concerns into three parts:
The Spring MVC framework provides a number of components that make it easy
to develop web applications using the MVC pattern. These components include:
● Controllers: Controllers are responsible for handling user requests and updating
the model data.
● Views: Views are responsible for displaying the model data to the user.
● Handlers: Handlers are responsible for mapping requests to controllers.
● Validators: Validators are responsible for validating model objects.
Spring Web MVC is a Java framework that is used to develop web applications.
It is built on the Model-View-Controller (MVC) design pattern, which separates the
application's concerns into three parts:
Spring Web MVC also provides a number of features that make it easy to develop web
applications, such as:
The following are the steps in the Spring bean life cycle:
1. Instantiation: The first step in the life cycle of a bean is instantiation. The Spring
IoC container instantiates the bean using the configured bean definition.
2. BeanPostProcessors: After the bean is instantiated, it is passed to any
registered BeanPostProcessors. BeanPostProcessors can modify the bean
before it is initialized.
3. Initialization: The next step in the life cycle of a bean is initialization. The bean is
initialized by calling its init() method. The init() method is called by the Spring IoC
container.
4. Use: After the bean is initialized, it is ready to be used. The bean can be used by
other beans or by the application code.
5. Destruction: When the bean is no longer needed, it is destroyed by the Spring
IoC container. The Spring IoC container calls the bean's destroy() method to
destroy the bean.
4 Explain Managing Transaction.
Ans:
● Transaction management is the process of ensuring that all of the operations
within a single transaction are either all committed or all rolled back.
● This ensures that the database remains in a consistent state, even if an error
occurs during the transaction.
● Local transactions: Local transactions are managed by the application itself. The
application code must explicitly start and end the transaction.
● Distributed transactions: Distributed transactions involve multiple resources, such
as databases and web services. Distributed transactions are managed by a
transaction manager.
1. Start the transaction: This can be done explicitly by calling a method on the
transaction manager or implicitly by using a framework such as Spring.
2. Execute the operations: The next step is to execute the operations that are part
of the transaction.
3. Commit the transaction: If all of the operations succeed, the transaction is
committed.
4. Roll back the transaction: If an error occurs during the transaction, the
transaction is rolled back.
return rollNo;
this.rollNo = rollNo;
return name;
this.name = name;
Ans:
The Spring IoC container provides a number of features that make it an effective tool for
managing objects in an application. These features include:
● Object instantiation: The IoC container can automatically instantiate objects
based on their configuration.
● Object configuration: The IoC container can configure objects with properties
and annotations.
● Object dependency injection: The IoC container can inject dependencies into
objects at runtime.
● Object lifecycle management: The IoC container can manage the lifecycle of
objects, including their creation, destruction, and pooling.
unit-6
Ans:
3 What is HQL? How does it differ from SQL? Give its advantages.
Ans:
Advantages of HQL:
ans:
Ans:
The mapping file is an XML file that contains the following elements:
● class: Defines the Java class that is being mapped to the database table.
● id: Defines the primary key of the table.
● property: Defines a column in the table and the corresponding property in the
Java class.
Ans:
The following are some of the methods that can be used to get information about the
database using DatabaseMetaData:
Ans:
Refer Q2/Q5
Ans:
● Hibernate Query Language (HQL) is same as SQL (Structured Query Language)
but it doesn't depends on the table of the database.
● Instead of table name, we use class name in HQL. So it is database independent
query language.
Advantage of HQL
○ database independent
Ans:
1. Hibernate code will work well for all databases, for ex: Oracle,MySQL, etc. whereas
JDBC is database specific.
3. Query tuning is not required in Hibernate. The query tuning is automatic in hibernate
by using criteria queries, and the result of performance is at its best. Whereas in JDBC
the query tuning is to be done by the database authors.
4. With the support of the cache of hibernate, the data can be placed in the cache for
better performance. Whereas in JDBC the java cache is to be implemented.
14 What is the difference between first level cache and second level cache.
Ans:
attributes.
Unit-3 New Questions
13 What is doFilter() method? What are its parameters? Give its use with proper
example.
Ans:
Ans:
Session events
15 What is servlet filters? Give the necessary API for filters and explain their use
Ans:
A servlet filter is a Java class that intercepts HTTP requests and responses before they
are passed to a servlet. Filters can be used to perform a variety of tasks, such as:
17 Give the characteristics of the HTTP protocol and explain the GET, HEAD and PUT
methods of the HTTP protocol.
Ans:
The GET, HEAD, and PUT methods are the most common HTTP methods.
● GET: The GET method is used to retrieve a resource from the server. The
resource can be a file, a web page, or any other type of data.
● HEAD: The HEAD method is similar to GET, but it only retrieves the headers of
the resource. The headers contain information about the resource, such as its
size and last modified date.
● PUT: The PUT method is used to create or update a resource on the server. The
resource can be a file, a web page, or any other type of data.
Ans:
MVC stands for Model-View-Controller. It is a software design pattern that separates the
application into three parts:
● Model: The model represents the data and business logic of the application.
● View: The view is responsible for displaying the data to the user.
● Controller: The controller receives user input and updates the model and view
accordingly.
● The MVC architecture is a popular choice for web applications because it makes
the code easier to maintain and test.
● It also makes it easier to scale the application, as each part can be independently
developed and deployed.
● The MVC architecture is a powerful tool that can be used to create complex and
scalable web applications.
Ans:
Ans:
● The XML tag library is a collection of tags that can be used to parse, transform,
and manipulate XML data in JSP pages.
● The XML tag library is part of the JSTL (JavaServer Pages Standard Tag
Library),
● It is a collection of reusable tags that can be used to simplify the development of
JSP pages.
The XML core tags are a set of tags that provide basic functionality for working with
XML data. The following are the XML core tags:
● x:parse - The x:parse tag parses an XML document and stores the resulting XML
document object model (DOM) in the specified variable.
● x:out - The x:out tag evaluates an XPath expression and writes the result of the
evaluation to the current JSP writer.
● x:set - The x:set tag evaluates an XPath expression and stores the result of the
evaluation in a scoped variable.
14 Explain the action tags used to access the JavaBeans from a JSP page with
example.
Ans:
Here are the action tags used to access JavaBeans from a JSP page:
15 Show the use of JSP inbuilt objects: request and response, with their use in
application.
Ans:
Here are some examples of how to use the JSP inbuilt objects: request and response,
with their use in application:
● Request object: The request object is used to access information about the
HTTP request that was made to the JSP page.
● For example, you can use the request object to get the user's IP address, the
browser they are using, and the URL of the page that they were on before they
came to the JSP page.
● Response object: The response object is used to send information back to the
client.
● For example, you can use the response object to set the content type of the
response, to send cookies to the client, and to redirect the client to another page.
Ans:
</sql:transaction>
Ans:
● JSP exception handling is the process of handling errors that occur during the
execution of a JSP page.
● JSP exceptions can be handled using try-catch blocks or error pages.
Try-catch blocks
● Try-catch blocks are the most common way to handle JSP exceptions.
● A try-catch block consists of a try block and a catch block.
● The try block contains the code that is executed in the event of an error.
● The catch block contains the code that is executed if an error occurs.
Error pages