This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes JSF and the fly likes JSP in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSP in JSF" Watch "JSP in JSF" New topic


amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
Hi All,
Can I use scriplets to define a list inside a jsf file(.xhtml).


SCJP (97%), SCWCD (95%))
H Jetly
Ranch Hand

Joined: Aug 26, 2010
Posts: 41

Why would you want to use a scriplet?
Which scenario would a scriplet score over the managed bean ?

JSF gives you a managed bean, you can write all the code present in the scriplets in the managed bean.

Harsh Jetly
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16395

It's not even that good an idea to use scriptlets on plain old JSPs, except in occasional small doses.

Scriptlets are logic. JSF is an implementation of MVC. In MVC, you don't put logic on the View.

Also, JSF is not a linear translation of the View definition into Java code the way JSPs are. Instead the view is compiled into a data tree. Positional logic such as JSTL and scriptlets don't fit into the tree and the results can be unpredictable. And usually bad.

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: JSP in JSF