Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

351.

What is the use of jsonValidation in struts?

Answer»

jsonValidation INTERCEPTOR is UTILIZED to PERFORM AJAX VALIDATION.

352.

Lists the bundled validators in Struts?

Answer»

STRUTS framework OFFERS a number of built-in VALIDATORS which are called as bundled validators. These validators are for input validations such as email, phone number, user id.

Struts OFFER the following bundled validators.

  • requiredstring VALIDATOR
  • stringlength validator
  • email validator
  • date validator
  • int validator
  • double validator
  • url validator
  • regex validator
353.

Which technologies can be used at View Layer in Struts?

Answer»

You can USE the following TECHNOLOGIES in the view LAYER in STRUTS:

  • JSP
  • HTML
  • XML/XSLT
  • WML Files
  • Velocity Templates
  • Servlets
354.

How we can configured action mapping in Struts?

Answer»

To CONFIGURE the Struts2 action mapping we have to add an action NODE inside the configuration file struts.xml.

Here is an EXAMPLE for this:

<action name="*welcome" class="example.action.mapping.LinkAction" method="EXECUTE">

     <result name="success">/welcome.jsp</result>

     <result name="error">/error.jsp</result>

</action>

355.

What are the Core classes of Struts Framework? Explain

Answer»

There are 5 core classes in STRUTS FRAMEWORK:

  • ActionServlet
  • ActionForm
  • Action
  • Action Mapping
  • ActionForward

 

This is one of the most repeatedly ASKED Java Struts 1.2 interview QUESTIONS and answers.

356.

Explain the difference between Jakarta Struts and Apache Struts?

Answer»

Technically, there is no difference between them Apache Struts and Jakarta Struts. They are both similar. Craig McClanahan created Struts and donated it to Apache FOUNDATION. Later, it EVOLVED as a Jakarta PROJECT and gained popularity in the J2EE community.

357.

What do you mean by OGNL?

Answer»

OGNL or Object-Graph Navigation Language is an open-source Expression Language that allows the navigation of objects (through syntax) for specifying symmetrically settable VALUES. The syntax provides a HIGH level of ABSTRACTION for NAVIGATING object graphs. This feature allows for simple array manipulation.

358.

What do you mean by tiles in Struts?

Answer»

Tiles are used for creating reusable PRESENTATION components. When using Tiles, first define a BASE layout with various sections. Next, define jsp page that should fill the CORRESPONDING regions in an external configuration file.

 

There are two ways to SPECIFY definition and attributes of Tiles - JSP Tile Definition and XML Tile Definition.

359.

What do you mean by DynaActionForm?

Answer»

In Struts, DynaActionForm is a FEATURE which allows the dynamic CREATION of ActionForm beans through the XML configuration. In such applications, FORM beans are virtual and not hard-coded ActionForm classes.

This reduces the tedious PROCESS of MANAGING and creating ActionForm classes.

360.

How can we display validation errors on JSP page?

Answer»

Validation error ARISES when a user enters invalid data format into the FORM. In order to validate this data, Struts enables the developer or PROGRAMMER with the Validator() method for validating the data from the client side as WELL as the server side. You can display ERRORS in the JSP page by using this syntax:
SYNTAX: <html:error/>

361.

What is the difference between validation.xml and validator-rules.xml files in Struts?

Answer»
S.noValidator-rules.xmlVALIDATION.xml
1.Defines standard validation routinesDefines validations that apply to FORM bean
2.For GLOBAL SPECIFIC rulesFor application specific rules
3.Contain logic for validationContains types of validation
362.

What is the configuration files used in Struts?

Answer»

The Struts FRAMEWORK uses one or more CONFIGURATION FILES to load and create REQUIRED application-specific components. These configuration files allow the components to be declaratively specified, rather than having hardcoded behavior and information. This can give you the flexibility to provide your own extensions. Based on XML format, configuration files can be validated against Struts DTD.

 

We can configure with the help of few important configuration files like struts.xml, web.xml,strutsconfig.xml and struts.properties

363.

Explain design patterns which is used in Struts?

Answer»

Struts use the MODEL 2 MVC architecture. The controller takes the command design pattern and the action classes have the adapter design pattern. In addition, the process() method of RequestProcessor USES template method design pattern.

This framework also implements the J2EE design patterns:

  • SERVICE to Worker
  • Dispatcher VIEW
  • Composite View (Struts Tiles)
  • Front Controller
  • View Helper
  • Synchronizer Token
364.

What do you mean by ActionMapping?

Answer»

ActionMapping represents the INFORMATION that is known to REQUESTPROCESSOR about the mapping of a specific request to a specific Action class. This instance is used to select an Action and then passing on to that Action, THUS providing access to configuration information included in the ActionMapping object.

365.

What is validate() and reset() functions?

Answer»

validate() is like a HOOK that can be overridden by different subclasses for performing validations on INCOMING data. This method gets called after a Form BEAN gets populated with incoming data. This method INCLUDES return type ActionErrors.

Syntax is:

public ActionErrors validate(ActionMapping mapping,HttpServletRequest REQUEST)

reset() is a method that gets overridden by subclasses. It is a hook that gets summoned before FormBean gets populated with request data from HTML. Using this method, all form fields get reset.

Syntax is:

public void reset() {}

366.

What do you mean by ActionForm?

Answer»

An ActionForm is a JavaBean that is associated with ActionMappings and HANDLES session state for the apps. The ActionForm object POPULATES AUTOMATICALLY on the server side when any set of DATA is entered on the client side.

If you are preparing for STRUTS interviews, you can read Struts interview questions and answers for freshers for clarity and insight.

367.

What do you mean by ActionServlet?

Answer»

ActionServlet is LIKE a "controller" in the MVC architecture for WEB apps which is known as Model 2. The requests to server pass through the controller, which is RESPONSIBLE for managing requests.

The USUAL flow in struts begins with the ActionServlet and call to process() method of RequestProcessor.

368.

How we can controlled duplicate form submission in Struts?

Answer»

DUPLICATE form submission can occur when you by refresh the page, PRESS back button, or if there is a virus in your machine.

There are 2 ways to prevent duplicate REQUESTS:

  • Through isTokenValid() method
  • By managing clearing REQUEST object.
369.

Explain the difference between DispatchAction and LookupDispatchAction in Struts?

Answer»
S.noDispatchActionLookupDispatchAction
1.Parent class of LookupDispatchActionSubclass of Dispatch Action
2.More useful if not USING INTERNALIZATION functionUseful when using Internalization
3.Not useful in I18NUseful in I18N
370.

How we can Install Struts?

Answer»

Installation process can be DIVIDED in four steps that's are GIVEN below:

  • Setup JAVA Development Kit
  • Setup Apache Tomcat
  • Setup Eclipse
  • Setup Struts2 LIBRARIES
371.

What is the differences between Struts1 and Struts2?

Answer»
S.noStruts 1Struts 2
1.Form BEANS define properties, SETTERS and gettersGetters and Setters are defined in action classes
2.Execute() method exposes servlet API for TESTINGDependency Injection simplifies the testing process
3.Multiple tag librariesThe single library includes all tags
4.RequestProcessor class PRESENTInterceptors present
372.

What is the difference between struts and spring? Explain

Answer»
S.noSpring MVCStruts
1.NoninvasiveInvasive
2.Loosely coupledTightly Coupled
3.LAYERED ARCHITECTURENot layered architecture
373.

Explain the components of Struts?

Answer»

Following are the key components of Struts:

  • JSP Programs or View LAYER Resources
  • FormBean Class Java Class or Controller Layer Resources
  • Action Servlet Built-in Controller Servlet or Controller Layer Resources
  • Action Class Java Class or Controller Layer Resources
  • WEB.xml DEPLOYMENT Descriptor FILE of the web application
  • Struts Configuration File XML File or Controller Layer Resources
374.

What is Struts? Explain

Answer»

Struts is a FREE, MVC-based, open-source framework that helps developers create modern Java applications. This framework prefers convention over configuration and is EXTENSIBLE through a plugin architecture.

Struts was INITIALLY built by CRAIG McClanahan. The first stable version was released in June 2001. Struts 2.0 was released in 2014.

375.

How we can use JavaScript with JSP Pages?

Answer»

As JAVASCRIPT is client-side script and JSP is a server-side script, developers can attach a FORM VALIDATION to a JSP page to redirect JavaScript content and HTML page.

376.

What are the difference between JspWriter and Servlet PrintWriter?

Answer»

JSP PrintWriter is object directly RESPONSIBLE for writing the CONTENT in RESPONSE, whereas JspWriter uses the PrintWriter object BEHIND the scene while OFFERING buffer support. After the buffer support is flushed or full, JspWriter uses the object in PrintWriter to write the content into a response.

377.

How we can configure init params in JSP?

Answer»

Developers can CONFIGURE init PARAMS in JSP similar to the SERVLET in the web.xml FILE. We have to configure JSP init-params with servlet and servlet-mapping element. PUT the JSP page location in the JSP-file element.

378.

What are the steps for creating custom tags in JSP?

Answer»

To CREATE a CUSTOM tag in JSP, use the following steps.

  • Create the tag HANDLER class first
  • Then, create the TLD file
  • Finally, create the JSP file
379.

List all tags that are provided in JSTL?

Answer»

Based on function, JSTL tags are categorized into five types, which are CORE Tags, Formatting and LOCALISATION Tags, SQL Tags, XML Tags and FUNCTIONS Tags.

380.

What do you mean by JSTL?

Answer»

The JSP Standard TAG Library or JSTL is a set of tags created to SIMPLIFY the JSP development. The JSTL tags help in FAST development, CODE reusability and eliminate the required use of SCRIPTLET tags.

381.

What is the differences between the JSP custom tags and java beans?

Answer»
  • Custom tags are used to MANIPULATE the JSP content, whereas JAVA beans can’t be manipulated.
  • Java beans are EASY to implement compared to custom tags which are tedious to implement.
  • Custom tags contain self-contained behaviour, but Java beans are defined in one SERVLET and it is used in the JSP PAGE or different servlet.
382.

What are the difference between ServletContext and PageContext?

Answer»

In JSP, the SERVLETCONTEXT shares information about the container in which the servlet is running in. This can be SET up in the WEB application descriptor. There can be only one v ServletContext per web application. Compared to this, the PageContext gives the servlet information about the REQUEST that it is currently managing and CONTAINS information about the request, the response object, the session, and also a reference to the ServletContext of the web application.

383.

What is in JSP?

Answer»

This action TAG is used to instantiate or locate a bean class. Depending on the scope, it doesn’t create the bean if the bean OBJECT of the Bean class is ALREADY created. This JSP action tag has five attributes, which includes Id, Scope, Class, TYPE and Bean NAME.

384.

List the different scope values for the tag in JSP?

Answer»

This tag is required to use any Java object present in the JSP PAGE.

The scope VALUES for tag are as following: application, request, page, SESSION, etc.

385.

How we can include the result of another page in JSP?

Answer»

So MANY mechanisms are available through which the results of ANOTHER PAGE can be included in JSP.

There of primary mechanisms used by developers are

  • INCLUDE directive
  • jsp:include element
  • Codas and preludes
386.

Explain the JSP implicit objects?

Answer»

Created by JSP Engine during translation phase, while translating JSP to Servlet, JSP implicit objects are crafted inside service METHOD and can be used directly within scriptlet without initializing and declaring them. In JSP, a total number of 9 implicit objects are AVAILABLE as FOLLOWING, Out, Request, Response, Session, APPLICATION, Exception, Page, PAGECONTEXT, and config.

387.

Define Scriptlet, Expression and Declaration in JSP?

Answer»

A JSP expression is used to put the Java values directly into the output. It has the FORM of &LT;%= Java expression %>. JSP scriptlets are more than the simple expression and used to insert complex code into the service() method of the GENERATED servlet. Whereas, a JSP DECLARATION defines fields or methods that get inserted into the main body of the servlet class.

388.

What are different types of comments used in JSP?

Answer»

Basically, there are two TYPES of COMMENTS allowed in the JSP, hidden comments and output comments.

 

The hidden comments of JSP don’t appear in the generated output in the HTML (EX: <%-- This is hidden comment --%&GT;), while output comments arrear in the generated output ex: <!-- This is output comment -->).

389.

Explain JSP lifecycle methods?

Answer»

The JSP LIFECYCLE METHODS are as following:

  • jspInit() : It OPERATES to initialize the servlet instance. Before CALLING any other method, its call is made.
  • _jspService() : It passes the request and the response subjects. You can’t override the method.
  • jspDestroy(): The container calls this when its instance is about to DESTROY.
390.

What is the difference between servlet and JSP?

Answer»

JSP is a dynamic content generating webpage scripting language, WHEREAS servlets are programs that operate on a WEB or application server and ACT as a middle layer between a request coming from APPLICATIONS on the HTTP server, or a web browser or other HTTP client and database.

391.

What do you mean by Custom Tag in JSP?

Answer»

A JSP custom tag is a user-defined JSP language ELEMENT. A JSP page which contains a custom tag is GENERALLY transcribed into a servlet. Then, the custom tag is converted to OPERATIONS on an object CALLED a tag handler. The custom TAGS can be created with JSP tag extensions that let developers insert these new tags directly into a JSP.

392.

How do you enable and disable sessions using JSP?

Answer»

The session in a JSP page can be disabled by SETTING the session attributes to false. The following can be exampled to disable the session object using page directive: &LT;%@ page session="false" %>

393.

What do you mean by JSP Directives?

Answer»

These are the messages to JSP container, and they provide global information for an entire JSP page. JSP directives are used by developers to GIVE special instruction to a container for translation of JSP to servlet code. These directives can contain many attributes by comma separated as key-value pairs. JSP directives are DESCRIBED in &LT;%@ %&GT; TAGS.

394.

What are the advantages of JSP?

Answer»

Using JSP has numbers of benefits, such as

  • It allows tag-based programming
  • Suitable for both Java and non-Java programmers
  • Allows developers to USE separate PRESENTATION logic
  • Highly INCREASES readability of code because of tags
  • Easy to learn and APPLY
395.

What is the difference between include directive and include action?

Answer»

Here are a few crucial differences between these two:

  • Include DIRECTIVE is processed at the translation time, but include action is processed at the request time.
  • Include directive USES both absolute and relative path, whereas include action only uses a relative path.
  • Include directive only uses the contents of the RESOURCE, while include action process DYNAMIC CONTENT resource.
396.

What is JSP and why it is used?

Answer»

JSP or JavaServer Pages is a SOFTWARE technology used to develop to DYNAMIC interactive web pages based on HTML or XML while controlling the content or appearance of web pages with the use of servlet containers. It has s wide a range of applications and SEPARATES BUSINESS logic from the PRESENTATION layer.

397.

What do you mean by Push parsing and Pull parsing?

Answer»
398.

What do you mean by XML signature?

Answer»

An XML signature is used to SIGN in RECOURSE outside its containing document of XML. It’s also called the enveloped signature.

399.

what is JAXP used in Web Service?

Answer»

In web service, JAXP is used to process XML data using applications WRITTEN in the JAVA programming language. It works with a pluggability LAYER that ALLOWS you to plug in an IMPLEMENTATION of the DOM or SAX APIs.

400.

Lists some standards used in web services?

Answer»