wood burning stoves 2.0*
The moose likes JSF and the fly likes Can I use jsps and jsfs both in my application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Can I use jsps and jsfs both in my application?" Watch "Can I use jsps and jsfs both in my application?" New topic
Author

Can I use jsps and jsfs both in my application?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi everybody, I am Chaitanya, I got a doubt, can I use jsps and jsfs both in one single appliation, can a jsp communicate with jsf, besides I dont have any knowledge about jsf, I am just asking because I got a doubt.

Thank you all in advance. Have a good day.


Love all, trust a few, do wrong to none.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

JSF pages are JSPs. (unless you are talking about Facelets, but that is a different topic) They just use a set of tag libraries that are specific to JSF and it's own lifecycle. JSF pages communicate via managed beans (some form of a controller). I don't know about communication between a non-JSF JSP and a JSF page itself via the managed bean. You'll probably have better luck with this in the JSF forum, so I'll move it there.


GenRocket - Experts at Building Test Data
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thank you Gregg, actually I was in a dilemma where to post this question. At last I chose jsp forum.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

I hate to contradict you, Gregg, but JSP JSPs are not "real" JSPs!

JSF is a Model/View/Controller system where the ".jsp" or ".xhtml" files are View prototypes.

In a normal JSP, the JSP is compiled to produce a servlet and the tags are enlisted in the execution of that servlet. Also, the URL is implicitly mapped to that servlet. In JSF, a URL mapping in web.xml routes JSF URLs to the FacesServlet. The FacesServlet is responsible for getting the View Prototype compiled into internal JSF constructs. This is one of the prime reasons that logic-oriented JSTL and scriptlets give so many problems when used in JSF View definitions.

It is perfectly legal to mix JSPs, Servlets, and even other frameworks such as Struts into a JSF application. In some cases, that's even preferable, since, for example, it's easier for a custom servlet to create a PDF than to badger the JSF framework to do so, since JSF is normally trying to render HTML, not PostScript. The difference between a JSP and a ".jsp" that's actually a JSF View prototype is strictly in whether or not the URL that makes the request matches the pattern that maps URLs to go to the FacesServlet. If it matches, it's JSF. If it doesn't, it's processed as a traditional JSP. If the JSP has JSF tags but is executed as though it were a traditional JSP, unhappiness results, as many of us have discovered to our sorrow. For one thing, the FacesContext won't have been constructed.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Tim Holloway wrote:I hate to contradict you, Gregg, but JSP JSPs are not "real" JSPs!


Don't ever worry about that. As long as we get the right info out there, I'm all for being contradicted.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

Gregg Bolinger wrote:
Tim Holloway wrote:I hate to contradict you, Gregg, but JSP JSPs are not "real" JSPs!


Don't ever worry about that. As long as we get the right info out there, I'm all for being contradicted.


Well, those of us who never make mistakes feel pain for those who do.

That should have been 'JSF JSPs are not "real" JSPs!'

I didn't make a mistake. My keyboard has a life of its own!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I use jsps and jsfs both in my application?