Java Interview Questions -47

Java Interview Questions -47

1. What is deployment-descriptor (web.xml) ?

deployment-descriptor is an xml file that provides configuration and deployment information for the web components comprise a Web application.

2. What is web container ?

A web container provides the hosting environment to a software component to run in. It is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet.A web container provides security, concurrency, lifecycle mnagement, deployment and other services for a web application.

3.What is load-on-startup element in deploymemnt descriptor (web.xml) ?

load-on-startup is a tag which appears inside <servlet> tag in web.xml.load-on-startup element tells the web container about the order of initiliazing the particular jsp page or/and servlet when the application server starts up.

4. What is the context root of a web applicaion ?

The context root of a web application tells which URLs web container will delegate to your application. If your application’s context root is myApp then any request for /myApp or /myApp/* will be handled by your application.

When the context root is set to /, which is known as the root context, It will respond to all requests.

5. When does a server call the destroy() method of a servlet ?

A. When a container unloads a servlet, It calls destroy() method after all service() calls have been completed, or a server-specific number of seconds have passed, whichever comes first.

6.Can we call destroy() method from init() in java servlet ?

Yes,we can destroy() method and it gets executed and initilization process continues.The imlicit question is, will the servlet get destroyed? No, it will. The meaning of destroy() in java servlet is, it gets executed just before the container going to destroy the servlet.

7.How can a servlet be threadsafe ?

There are two way of making a servlet threadsafe:
1. By implementing SingleThreadModel interface, which is a marker interface.
2. By using synchronize method, using synchronize keyword.

8. What is the difference between HTTP and HTTPs ?

When you need to ensure the integrity and privacy of information that is sent over the internet, you can use HTTPs instead of HTTP.HTTPs encrypts the information, by using symmetric encryption and digital certificates.

9. What is the difference between forward and redirect ?

When the sendRedirect() method is invoked, web container returns a response to browser indicating that a new URL should be requested and then browser reuests the new URL.Because of this extra round tip, a redirect is slower than a forward.
When the forward() method is invoked, request is sent to another resource on the server, without client being known.Because forward takes place on the seever without any communication with the browser, the performance of a forward is better than a redirect.

10. How can you set a default/home page for a web application ?

In web.xml file, using the welcome-file-list tag you can specify a welcome page for your web application. This tag can take any number of files.For example:
< welcome-file-list >
< welcome-file > index.jsp </ welcome-file>
< welcome-file> home.jsp</welcome-file>
The list of files checked in order from top to bottom to display.

11. What is a ServletContext ?

When a web application is deployed in a web container, then container assigns a servlet context object to it. There is only a single servlet context for a web application. A servlet can use the servlet context object to use external resources, log events and can store attributes name/value pair in it that other servlet objects in the same web application can use.

12. Is it possible for a web application to have more than one Servlet context objects ?

Yes, a web application may have more than one servlet context objects. If a web container is distributed and uses more than one jvm, then a web application may have a separate servlet context object for each jvm.

13.What are the benefits of Spring Framework?

Not a J2EE container. Doesn’t compete with J2EE app servers. Simply provides alternatives.POJO-based, non-invasive framework which allows a la carte usage of its components.
Promotes decoupling and reusability  Reduces coding effort and enforces design discipline by providing out-of-box implicit pattern implementations such as singleton, factory, service locator etc.
Removes common code issues like leaking connections and moreSupport for declarative transaction management Easy integration with third party tools and technologies.

14.What is Inversion of Control ?

Instead of objects invoking other objects, the dependant objects are added through an external entity/container.Also known as the Hollywood principle – “don’t call me I will call you”
Dependency injectionDependencies are “injected” by container during runtime.Beans define their dependencies through constructor arguments or properties Prevents hard-coded object creation and object/service lookup.
Loose coupling Helps write effective unit tests.

15.Explain the Spring Bean Definition ?

The bean class is the actual implementation of the bean being described by the BeanFactory. Bean examples – DAO, DataSource, Transaction Manager, Persistence Managers, Service objects, etc
Spring config contains implementation classes while your code should program to interfaces.
Bean behaviors include:
i.Singleton or prototype
iii.Initialization and destruction methods
vi.Beans can be configured to have property values set.

16.Explain Spring BeanFactory ?

BeanFactory is core to the Spring framework Lightweight container that loads bean definitions and manages your beans.Configured declaratively using an XML file, or files, that determine how beans can be referenced and wired together.
Knows how to serve and manage a singleton or prototype defined bean Responsible for lifecycle methods.Injects dependencies into defined beans when served Removes the need for ad-hoc singletons and factories

17.Explain the Spring ApplicationContext ?

A Spring ApplicationContext allows you to get access to the objects that are configured in a BeanFactory in a framework manner.ApplicationContext extends BeanFactory Adds services such as international messaging capabilities.
Add the ability to load file resources in a generic fashion.
Several ways to configure a context:
XMLWebApplicationContext – Configuration for a web application.
ClassPathXMLApplicationContext – standalone XML application context
Allows you to avoid writing Service Locators

18.Explain Transaction Management in Spring ?

1. DataSourceTransactionManager – PlatformTransactionManager implementation for single JDBC data sources. Binds a JDBC connection from the specified data source to the thread, potentially allowing for one thread connection per data source.
2. HibernateTransactionManager- PlatformTransactionManager implementation for single Hibernate session factories. Binds a Hibernate Session from the specified factory to the thread, potentially allowing for one thread Session per factory. SessionFactoryUtils and HibernateTemplate are aware of thread-bound Sessions and participate in such transactions automatically. Using either is required for Hibernate access code that needs to support this transaction handling mechanism.
3. JdoTransactionManager – PlatformTransactionManager implementation for single JDO persistence manager factories. Binds a JDO PersistenceManager from the specified factory to the thread, potentially allowing for one thread PersistenceManager per factory. PersistenceManagerFactoryUtils and JdoTemplate are aware of thread-bound persistence managers and take part in such transactions automatically. Using either is required for JDO access code supporting this transaction management mechanism.
4. JtaTransactionManager – PlatformTransactionManager implementation for JTA, i.e. J2EE container transactions. Can also work with a locally configured JTA implementation. This transaction manager is appropriate for handling distributed transactions, i.e. transactions that span multiple resources, and for managing transactions on a J2EE Connector (e.g. a persistence toolkit registered as JCA Connector).

19.Explian some of the DAO Support classes in Spring Framework ?

ii.Provides callback methods for row iteration
iv.Initializes Hibernate session factory
v.Provides templates to invoke Hibernate API or the session
vii.Provides template for iBatis SQLMaps
viii.Support similar to Hibernate template

20.What is Spring MVC?

A single shared controller instance handles a particular request type
controllers, interceptors run in the IoC container
Allows multiple DispatcherServlets that can share an “application context”
Interface based not class-based

21.What is ActionServlet?

ActionServlet is the Command part of the MVC implementation and is the core of the Struts Framework. ActionServlet creates and uses Action, an ActionForm, and ActionForward. The struts-config.xml file configures the Command. During the creation of the Web project, Action and ActionForm are extended to solve the specific problem space. The file struts-config.xml instructs ActionServlet on how to use the extended classes.

22. What is Jakarta Struts Framework?

Jakarta Struts is an open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java

23. How is the MVC design pattern used in Struts framework?

In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an application’s business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make an application significantly easier to create and maintain.
Controller–Servlet controller which supplied by Struts itself; View — what you can see on the screen, a JSP page and presentation components; Model — System state and a business logic JavaBeans.

24. What are the core classes of Struts?

Action, ActionForm, ActionServlet, ActionMapping, ActionForward are basic classes of Structs.

25. What is the design role played by Struts?

The role played by Structs is controller in Model/View/Controller(MVC) style. The View is played by JSP and Model is played by JDBC or generic data source classes. The Struts controller is a set of programmable components that allow developers to define exactly how the application interacts with the user.

26. How Struts control data flow? (Job Interview Favourites)

Struts implements the MVC/Layers pattern through the use of ActionForwards and ActionMappings to keep control-flow decisions out of presentation layer.

27. What configuration files are used in Struts?

These two files are used to bridge the gap between the Controller and the Model.

28. What helpers in the form of JSP pages are provided in Struts framework?


29. Is Struts efficient?

–The Struts is not only thread-safe but thread-dependent(instantiates each Action once and allows other requests to be threaded through the original object.
–ActionForm beans minimize subclass code and shorten subclass hierarchies
–The Struts tag libraries provide general-purpose functionality
–The Struts components are reusable by the application
–The Struts localization strategies reduce the need for redundant JSPs
–The Struts is designed with an open architecture–subclass available
–The Struts is lightweight (5 core packages, 5 tag libraries)
–The Struts is open source and well documented (code to be examined easily)
–The Struts is model neutral

30. How you will make available any Message Resources Definitions file to the Struts Framework Environment?

Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through <message-resources /> tag.
<message-resources parameter=”MessageResources” />

31. What is Action Class?

The Action Class is part of the Model and is a wrapper around the business logic. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class all the database/business processing are done. It is advisable to perform all the database related stuffs in the Action Class. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

32. Write code of any Action Class?

Here is the code of Action Class that returns the ActionForward object.
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class TestAction extends Action
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward(“testAction”);

33. What is ActionForm?

An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.

34. What is Struts Validator Framework?(Job Interview Favourites)

Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class.
The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.

35. Give the Details of XML files used in Validator Framework?

The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean.

36. How you will display validation fail errors on jsp page?

Following tag displays all the errors:

37. How you will enable front-end validation based on the xml in validation.xml?

The <html:javascript> tag to allow front-end validation based on the xml in validation.xml. For example the code: <html:javascript formName=”logonForm” dynamicJavascript=”true” staticJavascript=”true” /> generates the client side java script for the form “logonForm” as defined in the validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script.

38.What is Unicode ?

A standard defined by the Unicode Consortium that uses a 16-bit code page that maps digits to characters in languages around the world. Because 16 bits covers 32,768 codes, Unicode is large enough to include all the world’s languages, with the exception of ideographic languages that have a different character for every concept, such as Chinese.

39.What is transaction attribute ?

A value specified in an enterprise bean’s deployment descriptor that is used by the EJB container to control the transaction scope when the enterprise bean’s methods are invoked. A transaction attribute can have the following values: Required, RequiresNew, Supports, NotSupported, Mandatory, or Never.

40.What is transaction ?

An atomic unit of work that modifies data. A transaction encloses one or more program statements, all of which either complete or roll back. Transactions enable multiple users to access the same data concurrently.

41.What is URI ?

Uniform resource identifier. A globally unique identifier for an abstract or physical resource. A URL is a kind of URI that specifies the retrieval protocol (http or https for Web applications) and physical location of a resource (host name and host-relative path). A URN is another type of URI.

42.What is URL ?

Uniform resource locator. A standard for writing a textual reference to an arbitrary piece of data in the World Wide Web. A URL looks like this: protocol://host/local info where protocol specifies a protocol for fetching the object (such as http or ftp), host specifies the Internet name of the targeted host, and local info is a string (often a file name) passed to the protocol handler on the remote host.

43.What is URL path ?

The part of a URL passed by an HTTP request to invoke a servlet. A URL path consists of the context path + servlet path + path info, where Context path is the path prefix associated with a servlet context of which the servlet is a part. If this context is the default context rooted at the base of the Web server’s URL namespace, the path prefix will be an empty string. Otherwise, the path prefix starts with a / character but does not end with a / character. Servlet path is the path section that directly corresponds to the mapping that activated this request. This path starts with a / character. Path info is the part of the request path that is not part of the context path or the servlet path

44.What is Universal Description, Discovery and Integration (UDDI) project ?

An industry initiative to create a platform-independent, open framework for describing services, discovering businesses, and integrating business services using the Internet, as well as a registry. It is being developed by a vendor consortium.

45.What is Universal Standard Products and Services Classification (UNSPSC) ?

A schema that classifies and identifies commodities. It is used in sell-side and buy-side catalogs and as a standardized account code in analyzing expenditure.

46.What is unparsed entity ?

A general entity that contains something other than XML. By its nature, an unparsed entity contains binary data.

47.What is URN ?

Uniform resource name. A unique identifier that identifies an entity but doesn’t tell where it is located. A system can use a URN to look up an entity locally before trying to find it on the Web. It also allows the Web location to change, while still allowing the entity to be found.

48.What is user data constraint ?

Indicates how data between a client and a Web container should be protected. The protection can be the prevention of tampering with the data or prevention of eavesdropping on the data

49.What is user (security) ?

An individual (or application program) identity that has been authenticated. A user can have a set of roles associated with that identity, which entitles the user to access all resources protected by those roles.

50.What is transaction isolation level ?

What is transaction isolation level The degree to which the intermediate state of the data being modified by a transaction is visible to other concurrent transactions and data being modified by other transactions is visible to it.

51.What is virtual host ?

Multiple hosts plus domain names mapped to a single IP address.

52.What is W3C ?

World Wide Web Consortium. The international body that governs Internet standards. Its Web site is

53.What is role mapping ?

The process of associating the groups or principals (or both), recognized by the container with security roles specified in the deployment descriptor. Security roles must be mapped by the deployer before a component is installed in the server.

54.What is role (security) ?

An abstract logical grouping of users that is defined by the application assembler. When an application is deployed, the roles are mapped to security identities, such as principals or groups, in the operational environment. In the J2EE server authentication service, a role is an abstract name for permission to access a particular set of resources. A role can be compared to a key that can open a lock. Many people might have a copy of the key; the lock doesn’t care who you are, only that you have the right key.

55.What is rollback ?

The point in a transaction when all updates to any resources involved in the transaction are revWhat is RMI-IIOP ?
A version of RMI implemented to use the CORBA IIOP protocol. RMI over IIOP provides interoperability with CORBA objects implemented in any language if all the remote interfaces are originally defined as RMI interfaces.

56.What is role (development) ?

The function performed by a party in the development and deployment phases of an application developed using J2EE technology. The roles are application component provider, application assembler, deployer, J2EE product provider, EJB container provider, EJB server provider, Web container provider, Web server provider, tool provider, and system administrator.

57.What is root ?

The outermost element in an XML document. The element that contains all other elements.

58.What is server certificate ?

Used with the HTTPS protocol to authenticate Web applications. The certificate can be self-signed or approved by a certificate authority (CA). The HTTPS service of the Sun Java System Application Server Platform Edition 8 will not run unless a server certificate has been installed.

59.What is server principal ?

The OS principal that the server is executing as.

60.Are there any ODBC drivers that do not work with the JDBC-ODBC Bridge?

Most ODBC 2.0 drivers should work with the Bridge. Since there is some variation in functionality between ODBC drivers, the functionality of the bridge may be affected. The bridge works with popular
PC databases, such as Microsoft Access and FoxPro.

61.What causes the “No suitable driver” error?

“No suitable driver” is an error that usually occurs during a call to the DriverManager.getConnection method. The cause can be failing to load the appropriate JDBC drivers before calling the getConnection
method, or it can be specifying an invalid JDBC URL–one that isn’t recognized by your JDBC driver. Your best bet is to check the documentation for your JDBC driver or contact your JDBC driver vendor
if you suspect that the URL you are specifying is not being recognized by your JDBC driver.In addition, when you are using the JDBC-ODBC Bridge, this error can occur if one or more the the shared libraries needed by the Bridge cannot be loaded.
If you think this is the cause, check your configuration to be sure that the shared libraries are accessible to the Bridge.

62.What are the two major components of JDBC?

One implementation interface for database manufacturers, the other implementation interface for application and applet writers.

63.What is JDBC Driver interface?

The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendor driver must provide implementations of the java.sql.
Connection,Statement,PreparedStatement, CallableStatement, ResultSet and Driver.How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.

64.Which type of JDBC driver is the fastest one?

JDBC Net pure Java driver(Type IV) is the fastest driver because it converts the jdbc calls into vendor
specific protocol calls and it directly interacts with the database. Are all the required JDBC drivers to establish connectivity to my database part of the JDK?
No. There aren’t any JDBC technology-enabled drivers bundled with the JDK 1.1.x or Java 2 Platform releases other than the JDBC-ODBC Bridge. So, developers need to get a driver and install it before
they can connect to a database. We are considering bundling JDBC technology- enabled drivers in the future.

65.Is the JDBC-ODBC Bridge multi-threaded?

The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBCODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC.
Multithreaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading. Inaddition, deadlocks can occur between locks held in the database and the semaphore used by the Bridge.
We are thinking about removing the synchronized methods in the future. They were addedoriginally to make things simple for folks writing Java programs that use a single-threaded ODBC driver.

66.What is a meant by medium object mapping?

The application is designed around an object model. The SQL code is generated at build time. And the associations between objects are supported by the persistence mechanism, and queries are specified using an object-oriented expression language. This is best suited for medium-sized applications with some complex transactions. Used when the mapping exceeds 25 different database products at a time.

67.Why nobody at Sun wants to read the messages sent to [email protected]?

Because of the fact, that 99% of all messages is spam. It is recommended to post on JavaBeans forum, which is inspected by Sun engineers on a regular basis.

68.What is the relationship between Sun s JFCs and JavaBeans?

The JFC (Java Foundation Classes) is based upon the AWT (Abstract Windowing Toolkit), which has been part of the Java platform from the beginning. JFC effectively adds a richer set of visual elements for building JavaBeans components and applications. See the JFC web site for more information.

69.What is DelegatingVariableResolver?

Spring provides a custom JavaServer Faces VariableResolver implementation that extends the standard Java Server Faces managed beans mechanism which lets you use JSF and Spring together. This variable resolver is called as DelegatingVariableResolver

70.What are the different modules in Spring framework?

1.The Core container module
2.Application context module
3.AOP module (Aspect Oriented Programming)
4.JDBC abstraction and DAO module
5.O/R mapping integration module (Object/Relational)
6.Web module
7.MVC framework module

71.What is the Core container module?

This module is provides the fundamental functionality of the spring framework. In this module BeanFactory is the heart of any spring-based application. The entire framework was built on the top of this module. This module makes the Spring container.

72.What is Application context module?

The Application context module makes spring a framework. This module extends the concept of BeanFactory, providing support for internationalization (I18N) messages, application lifecycle events, and validation. This module also supplies many enterprise services such JNDI access, EJB integration, remoting, and scheduling. It also provides support to other framework.

73.What is AOP module?

The AOP module is used for developing aspects for our Spring-enabled application. Much of the support has been provided by the AOP Alliance in order to ensure the interoperability between Spring and other AOP frameworks. This module also introduces metadata programming to Spring. Using Spring’s metadata support, we will be able to add annotations to our source code that instruct Spring on where and how to apply aspects.

74. What is JDBC abstraction and DAO module?

Using this module we can keep up the database code clean and simple, and prevent problems that result from a failure to close database resources. A new layer of meaningful exceptions on top of the error messages given by several database servers is bought in this module. In addition, this module uses Spring’s AOP module to provide transaction management services for objects in a Spring application.

75.What are object/relational mapping integration module?

Spring also supports for using of an object/relational mapping (ORM) tool over straight JDBC by providing the ORM module. Spring provide support to tie into several popular ORM frameworks, including Hibernate, JDO, and iBATIS SQL Maps. Spring’s transaction management supports each of these ORM frameworks as well as JDBC.

76.What do you mean by Auto Wiring?

The Spring container is able to autowire relationships between collaborating beans. This means that it is possible to automatically let Spring resolve collaborators (other beans) for your bean by inspecting the contents of the BeanFactory. The autowiring functionality has five modes.

77.What is web module?

This module is built on the application context module, providing a context that is appropriate for web-based applications. This module also contains support for several web-oriented tasks such as transparently handling multipart requests for file uploads and programmatic binding of request parameters to your business objects. It also contains integration support with Jakarta Struts.

78.What is AOP Alliance?

AOP Alliance is an open-source project whose goal is to promote adoption of AOP and interoperability among different AOP implementations by defining a common set of interfaces and components.

79.What is Spring configuration file?

Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other.

80.What does a simple spring application contain?

These applications are like any Java application. They are made up of several classes, each performing a specific purpose within the application. But these classes are configured and introduced to each other through an XML file. This XML file describes how to configure the classes, known as theSpring configuration file.

81.What is XMLBeanFactory?

BeanFactory has many implementations in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions contained in an XML file. To create an XmlBeanFactory, pass a to the constructor. The InputStream will provide the XML to the factory. For example, the following code snippet uses a to provide a bean definition XML file to XmlBeanFactory.

82. Explain Bean lifecycle in Spring framework?

1. The spring container finds the bean’s definition from the XML file and instantiates the bean.
2. Using the dependency injection, spring populates all of the properties as specified in the bean definition.
3. If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.
4. If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.
5. If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.
6. If an init-method is specified for the bean, it will be called.
7. Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.

83.Give the difference between between ‘DispatchAction’ and ‘Action’.

A DispatchAction contains various different methods other than the standard execute() method in Action classes. These methods are executed based on some request parameter. For example, you can code in such a way that three buttons (namely Insert, Delete, Update) buttons correspond to different methods such as insert(), delete() and udpate(). The submit button in JSP would have the property that has the value which matches to any one of the methods defined in DispatchAction class.

84.What is pagination technique? How can you design them in struts?

Pagination is the technique where the bulk of results are split into different pages and only the information where the user can conveniently see are displayed in a page. (Like in Goooooogle). This can be achieved in many ways, but the simplest method is to have a query string (say http://www.testwebsite?pageNumber=2) would lead to information corresponding to resultset rows from 11 to 20. Assuming that you want to display 10 related rows of information, you can set the formula as follows:
Starting row = (pageNumber-1) * + 1 which is equal to 11.
Ending row = Starting row + which is equal to 20.

85.How can you populate the drop-down list using form properties?

There are many ways for this. But the best method is to use which defines collection that needs to be used to populate the drop-down list, the property to store the selected value and the collection that is used to display the labels (what we see in JSP page). For Example,
html:options collection=”form-collection-property”

86.What is the XML parser provided in struts? Can you use it for other purposes?

‘Digester’ framework. Yes we can use for our applications to store and parse our application-related data.

87.What is an “Action Class”?

The “Action Class” is part of the “Model” and is a wrapper around the business logic.The purpose of the “Action Class” is to translate the HttpServletRequest to the business logic.To use the “Action”, we need to subclass and overwrite the execute() method.
All the database and business processing is done in the “Action” class.It is advisable to perform all the database related work in the “Action” class.The ActionServlet (command) passes the parameterized class to ActionForm using the execute() method.
The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file according to the value of the returned ActionForward object.

88.Write code of any Action Class?

Here is the code of Action Class that returns the ActionForward object.
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class TestAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward(“testAction”);

89.What is an “ActionForm”?

An “ActionForm” is a JavaBean that extends org.apache.struts.action.ActionForm.ActionForm maintains the session state for web application and the “ActionForm” object is automatically populated on the server side with data entered from a form on the client side.

90.What is Struts Validator Framework?

The “Struts Framework” provides the functionality to validate the form data.It can be used to validate the data in the user’s browser as well as on the server side.
Struts Framework checks the JavaScript code and it can be used to validate the form data on the client browser.Server side validation of form data can be accomplished by subclassing your “form” Bean with DynaValidatorForm class.
The “Validator” framework was developed by David Winterfeldt as a third-party “add-on” to Struts.Now the Validator framework is part of the “Jakarta Commons” project and it can be used with or without Struts.
The Validator framework comes integrated with the Struts Framework andcan be used without any making any additional settings.

91.Describe the details of XML files used in the “Validator Framework”?

The Validator Framework uses two XML configuration files
1) validator-rules.xml and
2) validation.xml.
The validator-rules.xml defines the standard validation routines.
These are reusable and used in validation.xml to define the form specific validations.The validation.xml defines the validations applied to a form bean.

92.What is an Aspect?

An aspect is the cross-cutting functionality that you are implementing. It is the aspect of your application you are modularizing. An example of an aspect is logging. Logging is something that is required throughout an application. However, because applications tend to be broken down into layers based on functionality, reusing a logging module through inheritance does not make sense. However, you can create a logging aspect and apply it throughout your application using AOP.

93.What is a Jointpoint?

A joinpoint is a point in the execution of the application where an aspect can be plugged in. This point could be a method being called, an exception being thrown, or even a field being modified. These are the points where your aspect’s code can be inserted into the normal flow of your application to add new behavior.

94.What is an Advice?

Advice is the implementation of an aspect. It is something like telling your application of a new behavior. Generally, and advice is inserted into an application at joinpoints.

95.What is a Pointcut?

A pointcut is something that defines at what joinpoints an advice should be applied. Advices can be applied at any joinpoint that is supported by the AOP framework. These Pointcuts allow you to specify where the advice can be applied.

96.What is an Introduction in AOP?

An introduction allows the user to add new methods or attributes to an existing class. This can then be introduced to an existing class without having to change the structure of the class, but give them the new behavior and state.

97.What is a Target?

A target is the class that is being advised. The class can be a third party class or your own class to which you want to add your own custom behavior. By using the concepts of AOP, the target class is free to center on its major concern, unaware to any advice that is being applied.

98.What are singleton beans and how can you create prototype beans?

Beans defined in spring framework are singleton beans. There is an attribute in bean tag named ‘singleton’ if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans.
<bean id=”bar” class=”com.act.Foo”

99.What are the important beans lifecycle methods?

There are two important bean lifecycle methods. The first one is setup which is called when the bean is loaded in to the container. The second method is the teardown method which is called when the bean is unloaded from the container.

100.What is a Proxy?

A proxy is an object that is created after applying advice to a target object. When you think of client objects the target object and the proxy object are the same.

101.What are the general advantages and selling points of Servlets?

A servlet can handle multiple requests concurrently, and synchronize requests. This allows servlets to support systems such as online
real-time conferencing. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers that mirror the same content, and to partition a single logical service over several servers, according to task type or organizational boundaries.

102.Is HTML page a web component?

No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Even the server-side utility classes are not considered web components, either.

103.What can be considered as a web component?

J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.



This site uses Akismet to reduce spam. Learn how your comment data is processed.