File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF Vs JSP Vs JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF Vs JSP Vs JSTL" Watch "JSF Vs JSP Vs JSTL" New topic
Author

JSF Vs JSP Vs JSTL

Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
Hello All
Is there any guideline on when to use JSF, again when to use JSP and When to use JSTL?

Any reply would be greatly appreciated as I am preparing for my exams...
Regards
Mohamed Farouk


SCJP, SCWCD, SCBCD, SCEA 5
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

JSF already uses JSPs. JSTL can be used in current implementations of JSF as far as I know. Your question doesn't make a lot of sense.


GenRocket - Experts at Building Test Data
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
Hello Gregg

Thanks for your reply, As an architect trying to defend arguements about which techonology to use (JSP, JSF or JSTL) when asked, I have no clear answer.

Can i say use JSF as it is latest? - Not sensible...
Can i say use JSP as it has been stable and used before in many projects? Not sensible...
Can I say use JSP with Custom tags as I have used in previous project?
Can I say use JSP with JSTL as some one recommends?

Do you thing the above replies will convince a technologist who is looking for more sensible answer on my decisions.

There should be a guideline to differentiate these technologies and when to apply what.
The following is what I would like to provide as a answer to questions
I prefer to use JSP as my application UI screens do not requires that feature?

I prefer to use JSTL with JSP and avoid JSF if your screens and application does not require that feature?

I prefer to use JSF as your application requires this feature?

Hope it makes sense please can you comment on this, I would like to hear from you...
Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

JSTL+JSP is a concrete implementation. In very rough terms, like coding a set of instructions in assembly language.

JSF is an abstract implementation. Once again, very roughly, like coding specifications instead of instructions. Usually, the trade-off is between flexibility versus ease of development and maintenance.

You can use JSTL on JSF pages, but judiciously. Depending on the JSF release, JSTL may end up mucking around with JSF's understanding of the world.

However, please note that JSF/JSP is not "either/or". You can mix raw JSP's (and servlets), JSTL JSP's, JSF, and even Struts in the same webapp and they'll all play happily together. Use whatever is most effective for the action in question.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
Hello Tim
Great to hear from you, thanks for your comments, But one thing of what you said has made me ask you again the same question:

"Use whatever is most effective for the action in question"

So can you tell me what is most effective for what type of actions:
JSF is effective for actions like?
JSP is effective for actions like?
JSTL is effective for actions like?
Servlets is effective for actions like?

Hope those answers will give me the guidelines on what to use on what conditions...

Please help I am asking this as I was told there are lot of questions around best practice on usage of these when I am gonna sit for my SCEA beta architect exam...

I would appreciate your way of thinking on these technologies..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

I doubt my opinions would be a good reference for a certification exam, but one of the main reasons I've never bothered to acquire certs is that the Real World is generally more complex than the cert world.

I usually don't use straight JSP's these days except for one or two significant exceptions:

1. Login/password failed pages when using form-based authentication

2. Home page for a webapp.

When outputting non-HTML (such as PDF's or graphics), I normally use servlets, although sometimes JSPs are good for XML output. Struts action processors are also good for non-HTML output.

Anything with any sort of dynamic content - whether inbound (forms) or outbound (query/update results) I usually would be using JSF. I've always felt that Struts is probably capable of heavier workloads than JSF, but that's just a feeling not backed by hard measurements, and so far I haven't done anything that JSF couldn't handle.

The reasons for cases 1 and 2 above are as follows:

1. When using container-based authentication, the container hijacks and caches the original HTTP request, presents the login page, and (if successful) then resumes the original request. Because the login page is done out of the mainstream logic flow, it may find it difficult to access the full line of server services, depending on what server the app is running under. Thus, my login pages are minimalistic and don't make unneccesary infrastructure demands.

2. The site lead-in page (Home page, Hello page) is the place where users will go by default. Unlike some people, who think it's perfectly OK to put a Flash app on their lead-in page with all the secondary links done in Flash, I assume the worst of the user's browser. That is, primarily text displays (some of us use non-graphical browsers) and no assumption of support for cookies, JavaScript, Java applets or other features which might either be either switched off or never installed.

I have a 64-bit machine and Flash-only websites are just one big blank page to my browser. A major auto brand lost a sale to their non-Flash competitor recently.

There's another reason why my hello page is a JSP. As I recall, the hello page in a web.xml is a document, rather than a URL. JSF pages don't have document IDs, only their templates do, and you can't just bring up the template - to work properly you need the JSF context. So some of my sites have a hello JSP that does nothing but redirect to a JSF hello page URL. Such is life.

By the above, you can see I don't have any "silver bullet" rules, though I do have some standards designed to enhance user-friendliness.
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
Thats an answer. I got your view of looking at it . I really appreciate your time and effort to reply for my questions.

I thank you again for your great answer...
Mohamed Farouk
Ranch Hand

Joined: Jun 08, 2005
Posts: 249
Thats an answer. I got your view of looking at it . I really appreciate your time and effort to reply for my questions.

I thank you again for your great answer...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF Vs JSP Vs JSTL