Skip to main content

Struts

Dear Learner, these Java Interview Questions have been ask in latest interviews based on interview question i have write these questions on Java Interview Questions. As per Candidate experience, good interviewers hardly planned to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer.

1) What does the term Struts mean?
Struts could be defined as open source programming that can be utilized for creating website pages that are java based. Struts utilize different segments and packages like XML, Jakarta Packages, Java Beans, Resource Bundles and much more. Struts utilize the Model View Controller (MVC) design as help. For this situation by Model, it is being discussed about a business or a database, by seeing it is being referred to a page configuration code, and in last the controller implies the navigational code.

2) How the flow of various requests happens in Struts Application?
Struts Applications utilize the MVC designs, and the flow of demand occurs in a prescribed way:
The user associated with the view after clicking on a connection or after that they submit present a form.
After the interaction happens, the demand is sent to the controller.
The controller is that person considered who is responsible for forwarding the demand for better activity.
Action class chooses the functions, which additionally work for the business logic that will be actualized.
The last process is the response, it happens after the model layer sends it, and the client sees it on the screen.
3) What are the benefits of the Struts system?
The struts system is taking a shot at the MVC design. This ensures that the different layers of Struts are isolated appropriately, which additionally ensures the improvement and the customization of application easy. Since records of different configurations are utilized along this configuration of applications also turns out to be simple. Struts system is additionally open source programming and in this manner the best part, it is quite cost effective!
4) What is MVC Architecture ?
Model View Controller (MVC) is a design pattern used to perform changes in the application.
Model: Model is a term, which is referring to business or database. It stores the condition of the application. The model does not know the View and Controller segments.
View: View is referring to the Page Design Code. It must show the results of the client’s question. View modifies itself when any adjustments in the model happen.
Controller: Controller is alluding to navigational code. The controller will pick the best activity for every incoming request, produce the instance of that activity and execute that activity.
5) What is the Forward Action utilized for?
When we need to join a current application with struts, we have to utilize the Forward Action. Forward Action is also utilized at whatever point one needs to transfer the entire control starting with one place then onto the next, say, JSP to a nearby server. The Forward Action is also utilized when one needs to acquire the advantages of the usefulness of struts after the integration with Struts. For this situation, Servlets are never written again. Another utilization of forwarding Action is when a request is sent to different assets.
6) Briefly tell the two kinds of Form beans.
There are two different sorts of Form beans:
Request Scope: When the kind of Scope is requested, the values of the form beans are accessible with the present request.
Session Scope: When scope kind is a session, the values of the form beans are found for all of the requests in the ongoing session.
7) What is the role of Action Class?
An Action class in the struts application is utilized to deal with the demand.
It acts as an interface or correspondence medium between the HTTP request for coming to it and business logic used to build up the application.
Action class comprises of Request Processor, which act as a controller. This controller will pick the best action for every incoming request, produce the instance of that activity and execute that activity.
This ought to be in a safer manner because Request Processor utilizes a similar instance for various numbers of requests at a particular time.
8) At the point, you should go for Struts Framework?
Struts ought to be utilized when any or some of the accompanying conditions are valid:
Highly robust venture level application development is needed.
A reusable, highly configurable application is needed.
Loosely coupled, MVC established application is required with the clear isolation of different layers.
9) What do you mean by inner class and anonymous class?
Inner class: classes that are characterized by different classes.
The setting is a relationship performed between two different classes.
An inner class can get to private members and information.
Inner classes have two advantages:
Name control
Access control
Anonymous class: This class is a class characterized inside a technique without a name.

It is instantiated and pronounced in a similar strategy.
It doesn’t have explicit constructors.
10) What do you mean by struts.dev Mode?
The struts.dev Mode is utilized to ensure that the system is running in development mode or production mode by setting true or false. Struts.dev Mode is set to false production stage to diminish the effect of execution. As a matter, of course, it is “false.” It is utilized due to the accompanying reasons:
Asset Reloading: Resource package reload on each request
Modification: struts.xml can be modified without restarting or redeploying the application
Mistake Handling: The error happens in the application will be accounted for, as opposed to production mode.
11) What do you mean by action errors and what are the results they force?
Users of a web application may submit wrong information or no data at all. These errors must be gotten as near to the user interface as could be possible, rather than sitting tight for the center level or the database to tell segment can’t be inserted in the database because of expecting a non-null value.
Following are the outcomes of such programming practice:
Wastage of server time and assets. Like the request, this wastes time and assets also fail.
The negative effect on code quality as the probability of entering invalid information must be checked while utilizing or coding for business logic as they are the hardest codes of the framework and contain enough squares for if-else.
12) What do you mean by a custom tag?
Custom Tags can be depicted as Java classes, which are written by designers, which can be utilized as a part of the JSP utilizing XML markup. Custom tags can be considered as a class, which goes about as view partner beans that can be put into utilization without scriptlets, which are Java code snippets mixed with JSP markup.
JSP pages are produced and changed by page creators and can’t interpret the scriptlets. This blurs the detachment of different duties to be performed in a project. Custom Tags along these lines help in taking care of this issue as they are XML based and likes any markup language and can be effectively comprehended by the page author.

13) How can we work with error tags?
Working with error tags isn’t as complex as it looks. Error labels can be put in any place by including <html: errors/> into JSP. Not at all like others, error tags don’t have a body it also does not consist of any characteristics. The main function the error tag performs is to show the error in the place where the mistake tag is put utilizing three highlights – the header, the body and the footer.
14) Name the different types of actions found in Struts.
Various actions found in Struts are:
Forward Action
Include Action
Dispatch Action
Lookup Dispatch Action
Switch Action
15) What are the major differences between HTML tags and Strut specific HTML Tags?
The major differences between the HTML tags and Strut specific HTML tags are:
The nature of HTML tags is Static through the nature of Struts specific HTML tags are dynamic.
HTML is a coordinated in Struts however Struts have their particular tag libraries.
The tags for HTML can’t be user-defined however whereas in case of struts the tags could be user-defined.
16) What are the two different types of validations that the Validator Framework supports?
With the purpose of Validation of form information, Validator system is utilized. The two different validations are:
Customer Side Validation
Server-Side Validation
17) What do you mean by the abstract package in Struts2, and what is its utilization?
An abstract package usually characterizes inheritable segments, for example, interceptor, different interceptor stacks, result types, etc. But that doesn’t contain any actions. The way we announce a package as abstract is through the package elements attribute as abstract and setting the figure to “true.” By default in case, the abstract attribute is not specified it is false. Struts-default.xml is a major example of an abstract package.
18) What’s the utilization of resource bundle properties file in Struts Validation structure?
Resource bundle properties document is utilized to characterize specific error messages in key-value pairs for any conceivable errors that may occur in the code. This approach assists in keeps the code clean as the developer doesn’t have to dodge all error messages inside the code.
19) Why is Action Servlet a singleton in Struts?
In Struts system, action Servlet behaves like a controller, and this controller controls all of the requests made by clients. Action Servlet depends on singleton configuration pattern as just a single protest should be made for this controller class. Various threads are made later for every user request.
20) What’s the utilization of Struts.xml configuration file?
Struts.xml file is one the major configuration records of Struts system which is utilized to characterize mapping between URL and action. At the point when the controller receives a client’s demand, the controller utilizes mapping data from this file to choose appropriate action class.

Comments

Popular posts from this blog

The Future of Java Developers in the AI Decade

In this AI decade, Java developers are positioned to play a crucial role in various areas: 1. AI and Machine Learning: While Python is often the language of choice for AI and machine learning, Java still has its place, especially in enterprise-level applications and systems where stability, scalability, and security are paramount. Java developers can work on integrating AI and machine learning capabilities into existing Java-based systems or developing new AI-powered applications using Java frameworks like Deeplearning4j or Weka. 2. Big Data and Analytics: With the growing importance of big data analytics, Java developers can contribute to building robust data processing and analytics systems. Java is widely used in big data frameworks like Apache Hadoop and Apache Spark, enabling developers to work on distributed computing, data processing, and real-time analytics applications. 3. Cloud Computing: As more companies move their infrastructure to the cloud, Java developers can leverage t

Fresher Need to start from this technology

For freshers, some technologies are relatively simpler to start with due to their ease of learning and abundant resources available for beginners: 1. Python: Known for its readability and simplicity, Python is often recommended as a first language due to its clean syntax and vast community support. It's used in various fields like web development, data analysis, artificial intelligence, and more. 2. HTML/CSS: Fundamental for web development, HTML (HyperText Markup Language) and CSS (Cascading Style Sheets) are essential and relatively easy to grasp. They form the backbone of web pages and are essential for anyone interested in web development. 3. JavaScript:Alongside HTML and CSS, JavaScript is crucial for web development, adding interactivity and functionality to websites. It's beginner-friendly and essential for front-end development. 4. Java: Although it might have a steeper learning curve than Python, Java is widely used in enterprise applications, Android development, and

What is JDK, JRE and JVM?

What are JDK, JRE, and JVM: JDK :- Java Development Kit (in short JDK) is Kit which provides the environment to Develop and execute(run ) the Java program. For eg. You(as Java Developer) are developing an accounting application on your machine, so what do you going to need into your machine to develop and run this desktop app? You are going to need  J-D-K  for that purpose for this you just need to go to the official website of sun or oracle to download the latest version of JDK into your machine. Hence, JDK is a kit(or package) which includes two things i) Development Tools(to provide an environment to develop your java programs) and ii) JRE (to execute your java program). JDK is only used by Java Developers. JRE: - Java Runtime Environment (to say JRE) is an installation package which provides an environment to only run(not develop) the java program(or application)onto your machine. For eg(continuing with the same example) after developing your accounting application