• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error handling in JSF via servlet  RSS feed

 
harish shankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On click of the ok button from a JSF page, a servlet is called on a new window .Servlet creates a CSV file
which will be streamed back for a download.Now if there is a error in the servlet, how can this be shown in the parent JSF?
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem here is that if it's a servlet error, the servlet has to handle it.

HTTP is forbidden by its design architecture to send out 2 responses for 1 request, which is what would have to happen in order to update a JSF page when an error occurred outputting another page (response).

You could have the servlet post error information to a session object injected into a JSF backing bean, but the trick is to get the JSF view to update and display that info.

Although a JSF View can use AJAX polling to retrieve and display error/status info. Meaning that the JSF page can pull and display, but the servlet cannot directly push status into the JSF display.
 
harish shankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya true ..but in my case the servlet opens up in a window . Even we store the error in session the jsf refresh would have happened by this time.so would not be able to capture in jsf.
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter.

The servlet doesn't "open in a window". The servlet runs as a consequence of an HTTP request (probably an from HTTP link or JSF outputLink) to the servlet. The client was instructed to open a new window to hold the response that came back from the servlet instead of putting the output in the window that the link came from. Still only one request and one response.

Like I said. HTTP is the limiting factor here, not J2EE or JSF.
 
harish shankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!