Table of Contents
Why do we use servlet as controller instead of JSP?
However, most have a tradition to use servlets for controllers and JSPs for views. Since controllers are just java classes you can get full tool support (code completion etc.) from all IDEs. That gives better quality and faster development times compared to JSPs.
Why we use struts over servlets?
Struts is an open source framework that extends the Java Servlet API and employs a Model, View, Controller (MVC) architecture. It enables you to create maintainable, extensible, and flexible web applications based on standard technologies, such as JSP pages, JavaBeans, resource bundles, and XML.
What are the main advantages of using Struts framework over JSP and servlets?
Advantages of Struts
- Since Struts follow MVC framework, Java, JSP and Action classes are highly maintained and easy to understand for developers.
- The development time is less and this creates an advantage for the application developers.
- It is easy to maintain the applications due to the MVC framework.
What are the advantages of servlets?
The advantages of Servlet are as follows: Better performance: because it creates a thread for each request, not process. Portability: because it uses Java language. Robust: JVM manages Servlets, so we don’t need to worry about the memory leak, garbage collection, etc.
What is ActionForm in struts?
An ActionForm is a JavaBean optionally associated with one or more ActionMappings. Such a Bean will have had its properties initialized from the corresponding request parameters before the corresponding action’s execute() method is called.
What is the use of Struts config XML file?
The controller servlet uses a struts-config. xml file to map incoming requests to Struts Action objects, and instantiate any ActionForm objects associated with the action to temporarily store form data. The Action object processes requests using its execute method, while making use of any data stored in the form bean.
What are the benefits of Spring framework?
There are the following advantages of the Spring framework:
- Light Weight: Spring is a lightweight framework because of its POJO implementation.
- Flexible: It provides flexible libraries trusted by developers all over the world.
- Loose Coupling: Spring applications are loosely coupled because of dependency injection.
What is AngularJS and what are of its advantages?
Advantages of AngularJS It provides the capability to create Single Page Application in a very clean and maintainable way. It provides data binding capability to HTML. AngularJS code is unit testable. AngularJS uses dependency injection and make use of separation of concerns. AngularJS provides reusable components.
Why do we need servlets and JSP?
JSPs provide session management by default. Servlets require us to implement the business logic and presentation logic in the same servlet file. JSPs give us the flexibility to separate the business logic from the presentation logic using javaBeans. Servlets can handle extensive data processing.
What are the advantages and disadvantages of servlets?
Disadvantages of Servlet
- One servlet is loaded into JVM.
- When there is a request, there is a thread, not a process.
- Servlet is persistent until it destroys.
- Designing in a servlet is difficult and slows down the application.
- You need a JRE(Java Runtime Environment) on the server to run servlets.
What is the difference between servlet and Spring MVC controller?
A Servlet and a Spring MVC Controller can be used to do the same thing but they act on different level of a Java Application The servlet is a part of the J2EE framework and every Java application server (Tomcat, Jetty, etc) is built for running servlets. Servlet are the “low level” layer in the J2EE stack.
What is the difference between JSP and Servlet?
It can consist of either HTML or XML (combination of both is also possible) with JSP actions and commands. The full form of JSP is Java Server Pages. Servlet can accept all protocol requests, including HTTP, while JSP can only accept HTTP requests. In MVC architecture, servlet works as a controller while JSP works as a view for displaying output.
Can I have more than one controller in my struts application?
The predefined servlet class is the controller which uses structs-config.xml to manage or control your whole application. No, you can’t have more than one controller in your struts application its just against the MVC rule (that you cant have more than one servlet in your app) struts is designed based on MVC.
What is an ActionServlet in a struts application?
In a broader scope the ActionServlet together with the RequestProcessor and Action and the initialization info from struts-config.xml could be called the controller in a struts app. The controller is responsible for intercepting and translating user input into actions to be performed by the model.