wood burning stoves 2.0*
The moose likes JSF and the fly likes JSF and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF and servlets" Watch "JSF and servlets" New topic
Author

JSF and servlets

Charles Arminstice
Greenhorn

Joined: Sep 12, 2007
Posts: 4
Is it good programming style to mix JSF pages and navigation with entity persistence and Servlets?

From doing my "initial" research into it, it seems there are two different styles.

style 1 - using JSF with JSP pages and no pure servlet involved. Using backing beans to persist data.

style 2 - using JSP pages with Servlets and session beans and entity persistence classes.

Is this true? I see there are some ways to get JSF to work with servlets and entity persistence classes but it dosen't seem to be something JSF was naturally designed to do???

Then again, all this is from someone who just learned JSF last week so I could be wrong on the whole thing.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

JSF and servlets work together just file. The only restriction is that since JSF is itself accomplished via a servlet and only one servlet can receive an HTTP request, you have the choice of using JSF or of using a user-defined servlet, but not both on the same request.

That's not the handicap it may seem to be. A servlet is basically a dispatching device, and it's not really a good idea to place business logic - business logic should go in independent classes, and independent classes can be used by both JSF and servlets or JSPs.

In the case of a JSF page that needs to feed into a servlet for a task like having the servlet generate an XLS file or a PDF, this can be done by taking advantage of the fact that the JSF beans are just POJOs and therefore they're equally visible to both.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF and servlets
 
Similar Threads
JDO
JSP as client to EJB3
javaBeans vs regular objects
WAF or JSF in SCEA 5 Part 2
How to imbed servlet in JSF