aspose file tools*
The moose likes JSF and the fly likes How to get FacesContext.getCurrentInstance() from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to get FacesContext.getCurrentInstance() from a servlet" Watch "How to get FacesContext.getCurrentInstance() from a servlet" New topic
Author

How to get FacesContext.getCurrentInstance() from a servlet

xavi sala
Greenhorn

Joined: Mar 25, 2013
Posts: 1
HI,

I have a jsf form which submits payment details to a third party url which it returns the succes / error of the payment to my own servlet.

THe question is, how can I get my FacesContext from the servlet in order to add any error messages?

Regards,
Xavi
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Welcome to the JavaRanch, Xavi!

The FacesContext is not a durable data structure. It is created by the FacesServlet when a JSF URL request is received by the server and used to guide the lifecycle processing of that request. Once the request has been processed and the response has been sent back, it is destroyed. Therefore, the only servlet that can access the FacesContext is the FacesServlet itself. Likewise, since each request gets its own FacesContext, even code running under the FacesServlet cannot cache the FacesContext for later use. Once the current request is completed, the current FacesContext is useless.


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: How to get FacesContext.getCurrentInstance() from a servlet