Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get FacesContext.getCurrentInstance() from a servlet

 
xavi sala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic