views:

57

answers:

2

i´ve read a little about java's structure and could someone tell me if my view of all these components are correct:

JSP corresponds a View
Servlet corresponds a Controller
Bean corresponds a Model
Faces correspond layouts to render display

is this roughly correct?

+1  A: 

JSPs are view technology - HTML with Java embedded in it. Servlets should be used as controllers - they're Java classes that implement methods to read and write HTTP streams. In a web app Javabeans are usually the model - JSPs and other Java view technologies understand how to access properties of Javabeans, bind them to forms, etc. Faces is a separate stack JSF (Java Server Faces) is a component based web framework.

Nate
HTML with raw Java code embedded (using scriptlets) is discouraged since over a decade. You're supposed to use taglibs like JSTL to control the JSP page flow Expression Language to access any scoped attributes.
BalusC
Agreed - I was just trying for a short description.
Nate
+1  A: 

Yes, you're roughly correct.

Only, the Faces is more than just "layouts to render a display". JSF is a full fledged component based MVC framework which is built on top of the Servlet API. It uses the FacesServlet as the sole controller. It used to use JSP as view technology, which is now replaced by Facelets (XHTML) as per the new JSF 2.0 API. It uses the so-called backing beans as model. Then, you have taglibs/components which can be used in the view layer to generate HTML and uses Expression Language to associate the data/events with the model objects (the managed beans).

BalusC