Process-Display-Process (PDP) pattern

原创 2001年10月18日 10:25:00
Solution :- Process-Display-Process Desgin.
In this we adopt a approach which will process a small set of data first and then display the results to the user. While the user is having a look at the given results we can process the remaining results in the background and store them for further use.

Suppose we have a requirement, where we need to query on a table having a million records and fetch ten thound of them to display it to the user. But we sure can not display ten thousand records at a time, so we devide the records into the batches of 100 records each and the user can then scrole through the batches.

The Normal design would implement a Servlet and stateless session bean. The Session Bean queries the database based on the query criteria and then passes on the result set bound in PBV (pass-by-value) objects to the servlet. The servlet then Displays first batch and subsequent batches to the user based on this query data.

In this design (PDP pattern) we will make use of Servlets and Stateful session beans. The stateful session bean will have two methods, one for selecting the first batch, and another for selecting the remaining of the records. When the client enters some query criteria, these are passed to the first method of the stateful session bean (typically getFirstBatchResults() ). This method will then process the first batch results and send them back to the Servlet. The servlet displays the results to user making use of ( Response.flushBuffer() ). The query to database for selecting first batch can be made faster by using database features which allow you to select the "top n" records from the results.

After this, the control is still in the servlet. So we can call the second method of the Statefull session bean. This method ( typically getAllResults() ) will fetch all the records from the database and store them in the stateful session bean's privatte variable (arraylist). When the user wants to scroll through the records, we simply try to get that perticular batch from the stateful session bean. The getAllrecords() method needs to ommit the first batch results from subsequently adding to the arraylist.

Advantages :-
1. This gives the user a feeling that the response is quite fast.
2. Since the most of the data is stored in the Stateful Session Bean, It reduces the size of HttpSession.

Disadvantages / limitations :-
1. It can not be used where in the user is required to show the summery of all the results. In that case we need to process all the records before we can show anything to the user.
2. It results into two network calls for the same query criteria.
3. Thread safe ness of the methods needs to be checked, as we are operating on a private variable of the Stateful Session Bean.
4. If the user needs to sort the records based on some perticular columns, then this can not be implemented.
1 replies in this thread Reply
Read more Process-Display-Process (PDP) pattern.
Posted By: Bob Lee on October 17, 2001 in response to this message.
First, for an argument as to why a stateful session bean should absolutely not be used in this situation, I'll point you here:

Second, this is just a page-by-page iterator, and you can find it in the Sun blueprints.

The way you should set this up is with a stateless session bean with a single method, getRows(int startIndex, int pageSize,...).

If you're lucky enough to have jdbc 2.0, you can query the entire set and return only the window of rows requested using ResultSet.setFetchSize(pageSize) and ResultSet.absolute(startIndex). You can also use prepared statements here to make things more efficient. If you want to sort by a particular column, just pass it as a parameter to your session bean and generate it on the fly.

If you’re stuck with older drivers, you can use database-specific parameters to retrieve the results a page at a time.


PDP 详解 PDP(packet data protocol)分组数据协议,是外部PDN(PLMN外部包数据)网与GPRS接口所用的网络协议。它是GPRS连接的软硬件环境,指定GPRS连接的接入点...
  • lenk2010
  • lenk2010
  • 2013年03月20日 11:36
  • 2132

PDP上下文和PDP地址 S要接入外部PDN,MS还应具有与该PDN相应的地址,称为PDP地址,PDP地址是用于...
  • larryliuqing
  • larryliuqing
  • 2014年10月23日 11:49
  • 705


移动终端开机连接到运营商后,访问3G网络外部IPv6业务,主要包括以下三个过程: | 国内领先的通信技术论坛!i)i*t8S)p   (1)附着(ATTACH)。附着过程的目的是系统根据移动终端的...
  • jljerryliu
  • jljerryliu
  • 2013年03月13日 11:56
  • 2231


  • jackli8431
  • jackli8431
  • 2016年05月23日 14:38
  • 989


  • qq_21717607
  • qq_21717607
  • 2016年10月12日 11:16
  • 111


通过串口发送数据到远程服务器上面 串口调试: AT+CIPHEAD=1  //1----GPRS 接收方式       ok AT+CIPSTART="TCP","","50...
  • robinson_911
  • robinson_911
  • 2013年10月12日 17:13
  • 1602


  • u011615963
  • u011615963
  • 2013年11月27日 10:29
  • 1680


拨号脚本打印的信息 AT> AT+ZEACT=2//LTE 接入技术 LTE-TDD Pref AT AT AT AT AT AT> AT+ZNCARD=1//1:切换为 Lin...
  • jinchengzhou
  • jinchengzhou
  • 2017年05月26日 14:17
  • 730


1. 正则表达式的应用        在给用户发送消息时通常情况会有相同的消息模板,但其中部分信息跟用户相关,因此需要对消息模板中的变量部分进行替换。而对于一个系统而言可能有很多套完全不同的模板。因...
  • woniu317
  • woniu317
  • 2016年08月11日 21:21
  • 9634


1 简介  Pattern的下载地址为:   Pattern是Python编程语言的一个Web挖掘模块。它具有数据挖掘工具(谷歌,...
  • qq280929090
  • qq280929090
  • 2017年04月27日 10:13
  • 565
您举报文章:Process-Display-Process (PDP) pattern