
Our first question is why we need one more framework in-spite of having so many frameworks and technologies like JSP, Servlet,Struts etc. Lets discuss some drawbacks of the existing technologies like JSP and Servlet.
- Reuability Problem:- If the web project was to be developed which has 2-3 or more web forms then using technologies like JSP and Servlet the programmers have to do repetitive coding for each web form but by using JSF we can define components for form and can reuse it by simply dragging and dropping on pages.
- Security Problem:- In JSP application, programmers have to directly work with HTTP request and response objects and application was unable to map HTTP requests to component- specific event handling on server. But using JSF its components , Actionlistner tags and event handler components can easily handle request response and validations are mostly done on client side.
For example if user submits the registration form then programmer has to write the code to get the values of each element on the form into a variable for further processing. When there is a need to retrieve the data from database and then again has to code for retrieving data and showing it on the form for editing, so these becomes tedious job which can be easily handled by defining JSF components for input output operations and reusing them as per requirement.
JSF Vs Struts
JSF and Struts both are based on the same MVC(Model-View-Controller) framework but they are different in handling the requests. The following are the differences
| Struts | Java Server Faces(JSF) |
|---|---|
| The heart of Struts is the Controller. Struts use the Front Controller Pattern and Command Pattern. A single servlet takes a request, translates HTTP parameters into a Java Action Form, and passes the Action Form into a Struts Action class, which is a command. The URI denotes which Action class to go to. The Struts framework has one single event handler for the HTTP request. Once the request is met, the Action returns the result back to the front controller for navigation. | JSF uses the Page Controller Pattern. Although there is a single servlet every faces request goes through, the job of the servlet is to receive a faces page with components. It then fire off events for each component and render the components using a render toolkit. The components can also be bound to data from the model. |
| Struts is geared to one event per request. | JSF can have several event handlers on a page. |
| In Struts our Action Forms have to extend Struts classes, creating another layer of tedious coding or bad design by forcing our model to be Action Forms. | JSF gives developers the ability to hook into the model without breaking layering. |
Jsp Discussion
- - Two forms in one JSP
- - PASS VARIABLES BETWEEN 2
- - Table data
- - Unable to laod the image
- - The Ultimate Web UI Frame




