• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF and servlets

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic