Enterprise Tech Tip: POST-REDIRECT-GET and JSF 2.0

JavaServer Faces co-spec lead, Ed Burns, is in the process of writing a follow up to his popular book JavaServer Faces: The Complete Reference. The new book,co-written with Neil Griffin, is titled JavaServer Faces 2.0, The Complete Reference. It's chock full of excellent tutorials about the latest version of JavaServer Faces (JSF) technology, JSF 2.0.

You can get a sneak peek into one of these tutorials, a tutorial that focuses on support in JSF 2.0 that makes it much easier to implement the POST-REDIRECT-GET pattern, or PRG for short. If you're not familiar with the PRG pattern, in short, it's a pattern described by Michael Jouravlev, in an August 2004 TheServerSide.com article titled Redirect After Post. In the article, Jouravlev described a problem that many web applications present, as follows:

All interactive programs provide two basic functions: obtaining user input and displaying the results. Web applications implement this behavior using two HTTP methods: POST and GET respectively. This simple protocol gets broken when an application returns a web page in response to a POST request. Peculiarities of the POST method combined with idiosyncrasies of different browsers often lead to an unpleasant user experience and may produce an incorrect state of the server application.

To address the problem, Jouravlev described a technique that he called POST-REDIRECT-GET, or the PRG pattern for short. The rules of the pattern are as follows:

  • Never show pages in response to POST.
  • Always load pages using GET.
  • Navigate from POST to GET using REDIRECT.

Burns says that previous versions of JSF technology violated the first of these rules by using POST for every page navigation. In navigating from one page to another in a JSF-enabled application, the JSF framework forwarded a POST request through the Servlet API's RequestDispatcher.forward( ) method. This caused a new Faces page to be rendered and returned to the browser in response to the postback request. However, thanks to a JSF contribution from the Seam team at JBoss, it is now much easier to do PRG with JSF 2.0.

If you want to learn more about this topic, read Burns's Tech Tip POST-REDIRECT-GET and JSF 2.0 The content of the tip is an adaptation of a section on PRG and JSF 2.0 in Burns's upcoming book.

Comments:

I really believe that these social networks will have a huge impact on what we can accomplish as groups, it'll help us be very organized and communicate.

Posted by Ed hardy on November 16, 2009 at 09:10 AM PST #

Welcome to buy top quality <a href="http://www.kicksnike1.com/">nike sb dunk</a>, dunks shoes with worldwide free shipping.We guarantee 100 % secure payment and low price.

Posted by cc on November 17, 2009 at 11:25 AM PST #

Thanks for your useful info, I think it's a good topic.

Posted by air jordan shoes on December 03, 2009 at 08:45 AM PST #

Thank you very much!
Your article is very useful!
Keep up the good work, Your article is really great and I truly enjoyed reading it. Waiting for some more great articles like this from you in the coming days.

Posted by fake watches on December 19, 2009 at 01:37 PM PST #

We are Rolex watch experts selling only the finest, top level condition, and preowned men's and ladies' Rolex watches, used Rolex watches, unused Rolex watches and new Rolex watches on the market. Our top priority is to provide every customer with the highest quality Rolex watch at the lowest price available. Browse our wide selection of Rolexes for sale.

Posted by replica watches on January 03, 2010 at 02:08 PM PST #

good thanks for sharing.

Posted by links of london on March 04, 2010 at 10:44 AM PST #

Great news. Thanks for sharing. I like tutorials, especially if they are excellent.

Posted by Rapidshare search on March 10, 2010 at 08:02 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

edort

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today