Monday Nov 16, 2009

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.

Friday Jun 26, 2009

Enterprise Tech Tip: A Sampling of EJB 3.1

Enterprise JavaBeans (EJB) technology has taken a number of knocks in the past. When it was first introduced some, perhaps many, cried that it was too complicated, with a lot of programming overhead that made the technology needlessly difficult to use.

Over time things have improved dramatically. Features such as annotations in EJB 3.0 made the technology much, much easier to use. Those ease-of-use advancements continue with the upcoming release of EJB 3.1, which will be included in Java Platform, Enterprise Edition (Java EE) 6. A preview version of Java EE 6 is currently available for download. The preview version includes a nearly complete implementation of EJB 3.1

If you want to learn about some of the new, cool features in EJB 3.1, see the Tech Tip, A Sampling of EJB 3.1, written by Ken Saks, the EJB 3.1 Specifical Lead.

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