Archive for November, 2007

Sex offenders web site - 314 CHAPTER 10 INFINITE DATA PATTERN client.listen

Friday, November 30th, 2007

314 CHAPTER 10 INFINITE DATA PATTERN client.listen = function( status, statusText, responseText, responseXML) { if( status == 200 && responseXML != null) { var objData = new Object(); objData.didFind = false; objData.verify = IterateResults; XMLIterateElements( objData, objData, responseXML); if( objData.didFind == true && IsActiveTransactionIdentifier( objData.transactionIdentifier) == true) { var spanElement = document.getElementById( GetResultField( objData.transactionIdentifier)); spanElement.innerHTML += “(” + objData.number + “)”; } } } The implementation of client.listen is a bit more complicated because the function has to process the received XML and ensure that the results are not stale. A stale result is a result that does not belong to the currently executing transaction identifier. The first step in the implementation of the client.listen method is to ensure that results have been successfully retrieved, where the HTTP response code is 200, and that the responseXML parameter is not null. As the contract relies on XML if the responseXML parameter is null, most likely the response was not encoded using XML and thus is not applicable in the context of the pattern. If the responseXML field can be processed, the XML data needs to be iterated by using the function XMLIterateElements. The results of the iteration are written to data members of the variable objData. Specifically, the data members transactionIdentifier, didFind, and number are manipulated. The data member transactionIdentifier represents the received transac tion identifier, and number represents the prime number found. The purpose of the data member didFind is to indicate whether the data members transactionIdentifier and number are valid. If the data member didFind is assigned a value of true, a result was found. But to process and display the result, the function IsActiveTransactionIdentifier first verifies that the result is not stale and belongs to an active transaction identifier. The implementation of the function IsActiveTransactionIdentifier will be covered shortly. If the retrieved result can be processed, the data member s objData.number value is added to the destination span element. To know which span element to update (results1 or results2), the function GetResultField is called to extract the span element identifier from the received transaction identifier. The found span element instance is assigned to the variable spanElement, and the value of the spanElement. innerHTML property is appended with the found prime number (objData.number). The function IsActiveTransactionIdentifier is used to determine whether the retrieved result is active and is implemented as follows: function IsActiveTransactionIdentifier( transactionIdentifier) { var reference = transactionIdentifier.charAt( 0); var valIdentifier = parseInt( transactionIdentifier.substring( 2)); if( reference == “1″ && valIdentifier == transactionIdentifier1Counter) { return true; }
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

CHAPTER 10 (Affordable web hosting) INFINITE DATA PATTERN between SendData1

Friday, November 30th, 2007

CHAPTER 10 INFINITE DATA PATTERN between SendData1 and SendData2 is that one function uses the identifier 1, and the other uses the identifier 2. For those readers who are cringing because of using the hard-coded numeric identifiers 1 and 2, well, you are right. There is a better way of writing the code, but it will not be illustrated here because that would make the explanation of the pattern more difficult. Here is the implementation of SendData1: function SendData1() { transactionIdentifier1Counter ++; document.getElementById( “result1″).innerHTML = “No Result”; var buffer = GenerateActionData( “1_” + transactionIdentifier1Counter, document.getElementById( ‘Number1′).value); client.send( “application/xml”, buffer.length, buffer); } Calling SendData1 means creating a new task on the server, thus invalidating the results of the old tasks that may be executing. The implementation of SendData1 begins with the incrementing of the first task transaction identifier (transactionIdentifier1Counter). Using a static random transaction identifier would result in the scenario where multiple requests would be sending results with the same transaction identifier, thus corrupting the results. As a new task is being created, the content of the result span element (result1) is cleared. The XML buffer that is sent is created by using the function GenerateActionData. The function GenerateActionData has two parameters; the first parameter is the transaction identifier, and the second parameter is the maximum number to calculate all primes for. The generated XML buffer is sent to the server by using the method client.send. Following is the implementation of GenerateActionData that generates the XML buffer: function GenerateActionData( transactionIdentifier, number) { return “” + “” + transactionIdentifier + “” + “” + number + “” + ““; } The implementation of GenerateActionData is a straightforward string concatenation. When the buffer is sent by using the client.send method, the server is responsible for translating the XML buffer into a task. The client.send method does not wait for a response and returns immediately without a response. The caller of client.send does not know if the task has been started or is working. The caller assumes everything went okay and will expect some results in the receiving part of the HTML page. Deciphering the Protocol The receiving of the results is started when the method client.start() is called as per the explanation in the Persistent Communications pattern. When a result is retrieved, the method reference of client.listen is called, which is implemented as follows:
We recommend high quality webhost to host and run your jsp application: christian web host services.

Space web hosting - 312 CHAPTER 10 INFINITE DATA PATTERN In

Thursday, November 29th, 2007

312 CHAPTER 10 INFINITE DATA PATTERN In the XML, the element TransactionIdentifier has an associated value of 1, and the XML element Number has an associated value of 20. When a result structure is generated, the XML will appear similar to the following: success 1 9 The main difference between the XML to be sent and received is the additional XML element Result to indicate a success. The Result element is necessary so that the client knows what to do with the XML content. For example, imagine sending a state that has incorrect data. The error condition is not generated on the sending of the data, but on the receiving of the data. This is due to the requirement of the Persistent Communications pattern and asynchronous communications. To indicate that an error has occurred, a result has to be sent with the error. Another reason for using the Result element is to indicate a finished operation, indicating that all results have been found and that the client will not receive any more results. There is one weakness with using simple transaction identifiers 1and 2: if a user sends an Action XML document with transaction identifier 1, and then shortly thereafter sends another Action XML document with the same transaction identifier, the results will be corrupted. The results are corrupted because two tasks would generate data using the same transaction identifier even though the state for each transaction identifier may be different. The solution is to create a unique transaction identifier for each and every sending of structured data that generates results. The following modified Action XML document references the corrected transaction identifier: 1_1 20 In the modified XML, the transaction identifier has encoding so that the first digit represents the first or second result field, and the second digit is the transaction identifier counter. The encoding of the transaction identifier seems arbitrary, and is arbitrary from the perspective of the server because only the client knows how to decipher the identifier. The server, when presented with the transaction identifier, does not attempt to decipher what the identifier means. The server is responsible only for cross-referencing the transaction identifier with the received and result data. Generating the Content for the Contract Having defined the contract between the client and server, the next step is to generate the content for the contract. The JavaScript code used to generate the state will be illustrated first, and then the code used to process the received results. For this explanation, it is assumed that the server sends and receives the data without any errors or problems. The data sent from the client to the server is created in either the function SendData1 or SendData2. For explanation purposes, the implementation of SendData1 is outlined. It is not necessary to explain SendData2 because it is nearly identical to SendData1. The main difference
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

CHAPTER 10 INFINITE DATA PATTERN No Result (Top web site)

Thursday, November 29th, 2007

CHAPTER 10 INFINITE DATA PATTERN
No Result

The HTML page implementation, like previous pattern implementations, includes a number of JavaScript files referenced by using the script HTML tag. Unlike previous patterns, on the client side the Infinite Data pattern does not reference any script files that implement a generic Infinite Data infrastructure. There is no Infinite Data infrastructure; the activity diagram illustrated in Figure 10-1 shows that all of the logic is application specific. The Infinite Data pattern does instantiate the ClientCommunicator type that is an implementation of the Persistent Communications pattern. The instantiated Persistent Communications pattern is assigned to the variable client, and the property baseURL is assigned to the file /ajax/ chap08/PrimeNumberHandler.aspx. The file /ajax/chap08/PrimeNumberHandler.aspx represents the server-side implementation of the Infinite Data pattern. The HTML page contains the HTML element table that contains four rows used to send and receive the Infinite Data state. When the buttons that have the onclick event handlers defined as SendData1or SendData2 are clicked, the structure is assembled and sent for processing to the server. The sent structure is stored in the input elements with the identifiers number1 and number2. When the result structures are received, they are processed and inserted into the span elements with the identifiers result1 and result2. Defining the Sending and Receiving Contract Before further illustrating the code on the client and server sides, the contract between the two sides needs to be defined. The contract in an Ajax application is the data that is sent between the client and the server. In the Infinite Data pattern implementation, there are two contracts: what the client sends as a structure to be processed by the server, and the result structures sent by the server and processed by the client. The state for the structure is stored in the HTML form inputfields, which happen to be text fields, number1and number2. When the appropriate button is clicked, the function SendData1 or SendData2 is called. What you should notice is that all of the identifiers are appended with a number to indicate whether the button represents the first task or the second task (or more appropriately called the first or second transaction identifier). When the results are generated using the transaction identifier, we know which span element, result1 or result2, the result structures are destined for. Let s say that the text field with the identifier number1 contains 20, and the button associated with the function SendData1 is clicked. The generated structure that is sent to the server is represented using the following XML: 1 20
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

310 CHAPTER 10 (Web hosting ecommerce) INFINITE DATA PATTERN Figure

Wednesday, November 28th, 2007

310 CHAPTER 10 INFINITE DATA PATTERN Figure 10-2 shows two text boxes; one text box has the value of 200, and the other has the value of 1000. Each text box represents the maximum number to find all primes. The result area is where the text No Result is displayed. The Send Data buttons are used to send the maximum number value to the server. The Start Communications and End Communications buttons are used to start and stop the Persistent Communications pattern. These two buttons are not necessary and can be automatically controlled by the Send Data buttons. They were kept in the HTML page to illustrate how the Persistent Communications and Infinite Data patterns work seamlessly together. Overall Implementation Details of the HTML Page The implementation of the HTML page will be presented as a series of code segments. The first code segment is the overall HTML page, with most of the implementation missing for clarity purposes. Then as needed each missing code segment will be illustrated and explained. The overall structure of the HTML page illustrated in Figure 10-2 is as follows:

Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Web hosting compare - CHAPTER 10 INFINITE DATA PATTERN As already

Wednesday, November 28th, 2007

CHAPTER 10 INFINITE DATA PATTERN As already indicated, using the CGI parameter as a task identifier is an example of a necessity practice. Regardless of the client calling the server and using the same task identifier, the same results would be generated. The problem with using a task identifier of 20 is that the task identifier has to be determined by the server, and not the client, adding a wrinkle to the solution. The implementation of the pattern is a server push, without user authentication. Looking back at the Persistent Communications pattern implementation, the server push used authentication, and that would seem to be a conflict in this implementation. The Infinite Data pattern uses a shopping cart approach, where the identification of the user will use an HTTP cookie. Using cookies or authentication is not a necessity, but a nice-to-have feature. Otherwise, anybody can access a specific task. For example, if the URL is /ajax/chap08/PrimeNumberHandler. ashx?task=1234, not using an HTTP cookie as an authorization mechanism would allow everybody to retrieve the results for task 1234. Implementing the HTML Client For the scope of the prime number application, the HTML client is used to define and process the prime number. The HTML client presents an HTML form consisting of a text box and button. The text box is used to define the maximum number for which all prime numbers are calculated. The button is used to submit the maximum number to the server. The results area displays the generated numbers. Figure 10-2 is the HTML page used to process two prime numbers. Figure 10-2. HTML page that processes two prime numbers
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Web design tools - 308 CHAPTER 10 INFINITE DATA PATTERN to

Tuesday, November 27th, 2007

308 CHAPTER 10 INFINITE DATA PATTERN to focus on the architecture and mechanics of the Infinite Data pattern. For those wondering, the prime number calculation routine is a brute force technique that tests whether a number is prime. What is desired with the implementation is the ability to display seemingly infinite data in a timely manner, hence the prime number algorithm is a secondary concern. Calculating the prime number of a large enough maximum value will require some time and allow the testing of multiple concurrently running tasks. The pattern implementation uses the Persistent Communications pattern. In the definition of the Persistent Communications pattern, there are three variations that can be implemented. The Infinite Data pattern uses the server push variation without implementing user identification. A server push is when the client sends a request to a generic URL, and the server responds with a specific URL used to process requests. In the case of the prime number calculation, the generic URL could be /ajax/chap08/PrimeNumberHandler, and the specific URL would be /ajax/ chap08/PrimeNumberHandler/1_101. It sounds ideal and would work if it were not for ASP.NET. One of the problems implementing the Infinite Data pattern is that infrastructures such as ASP.NET are not always implementation friendly. The problem is that the Infinite Data pattern uses URLs in a way that is not friendly with the default ASP.NET infrastructure. ASP.NET, unlike Java Servlet, does not understand the notion of generic URLs. When using ASP.NET, using a specific URL such as /ajax/chap08/PrimeNumberHandler.ashxwould be necessary. Some readers will remember that when the Permutations pattern was implemented, ASP.NET was used. The reason why the Permutations pattern worked is because ASP.NET HTTP modules were used. In Javaspeak, a module is a filter, and the module redirected to a specific URL. The difference is that one handler will process multiple requests associated with a URL and its descendent URLs. The Permutations pattern redirected to a URL used to process a single request. So one solution could be to have the generic URL redirect to something specific such as /ajax/chap08/PrimeNumberHandler/1_101.aspx. Again, the problem is that that does not work in ASP.NET. There has to be a file 1_101.aspx in the directory PrimeNumberHandler. The HTTP module could copy a file to satisfy the reference of the specific file. The solution, though technically possible, is not practically viable. The URL used in the server push is generated dynamically, and there could be hundreds of thousands of URLs. Managing hundreds of thousands of files is not an option. Another solution would be to attach a CGI parameter to the URL as follows: /ajax/chap08/ PrimeNumberHandler.ashx?task=1234. Attaching the CGI parameter would work, but it is not a best practice. Doing so is a so-called necessary practice as the infrastructure does not allow anything else. The problem of using CGI parameters in this context is that it conflicts with caching on the Internet. Another clever approach would be not to use the task identifier, but the URL /ajax/ chap08/PrimeNumberCalculatorTask.ashx?number=20. The new URL is saying, Please calculate the prime numbers up to the number 20. Using the URL in that manner is not bad idea, because then the answer for the prime numbers up to 20 could be cached. In fact, an optimization would be to cache the prime numbers calculated. Then as a larger number is referenced, only the difference between the previously largest value and new large number needs to be calculated. But we won t use that approach in this chapter because we would be diverting from using a classic implementation of the Infinite Data pattern. The optimizations illustrated for calculating the prime number are optimizations that could be used in the implementation of the prime number task. The overall infrastructure would remain identical, and focusing on the optimization would take attention away from implementing the Infinite Data pattern.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

CHAPTER 10 (Web hosting plans) INFINITE DATA PATTERN In the

Tuesday, November 27th, 2007

CHAPTER 10 INFINITE DATA PATTERN In the action boxes Server receives XML and XML is converted into task, the client-side structure is converted into data that is associated with a task. When the data is associated with the task, multiple tasks may process a single piece of data. More about multiple tasks and the data will be covered shortly. After the conversion action box is another black bar that indicates an execution of parallel task paths, where one path causes a thread to be spun off to start a task. The other patch represents the original thread, which is finished, as there are no further actions. The main reason for the execution of tasks is to start the thread(s) used to process the task(s). When the spun-off task executes, a result could be generated that is added to the result database, as indicated by the actions Task is processed and Result is marked as available. The diamond shape on the left side of Figure 10-1 represents a decision and the joining of server-side with client-side actions. What happens is that the client-side route is querying the server as defined by the action items Query serverand Query for available result. If there is a result available, the server converts the result into an XML content chunk that is sent to the client for processing. The action items Client receives XML, XML is parsed and converted into state, and State is processed represent the receiving and processing of the XML content chunk to generate some result. The action items of Figure 10-1 form a big-picture perspective showing a client-generated structure that is converted into data that is associated with a task that generates another result structure that is processed by the client. There is a disjoint in that the client has two parallel tasks running, and this means the logic used to send the structure is not the logic used to receive the result structure. In a nutshell, the left hand has no idea what the right hand is doing. The problem relates to two queries running on behalf of a single client. When the client receives a result, how does the client know which query the result belongs to? Putting this practically, imagine an HTML page with two text boxes. Each text box represents an instance of the same task, but different task data. Each text box starts the same task, resulting in two task instances executing with different data. The problems begin when the client retrieves a result. The receiving algorithm does not know which text box a result belongs to. The solution for the identification problem is to use a transaction identifier. In the activity diagram, the concept of the transaction identifier is not illustrated. It is not illustrated because the transaction identifier is a piece of information in the generated structure. The transaction identifier is generated by the client, sent to the server, sent to the executing task, and sent to any generated result. Then when the client receives a result, the client can associate the sent transaction identifier with a received transaction identifier. Thus the client can decipher which text box a result is destined for. From the perspective of the server, the transaction identifier is a black box and not processed. Combining the actions, activity diagram, and other details, the implementation of the Infinite Data pattern involves three major pieces: HTML client, task manager, and task implementation. The HTML client is used to send and receive the structures. The task manager is responsible for creating the task data, managing the tasks, and managing the results. The task implementation is the application logic, which in the case of this chapter is the prime number calculation and is responsible for the task data association and results generation. Implementation The Infinite Data pattern implementation in this chapter will be a simple example of calculating all prime numbers up to a specified value. So if the specified value were 9, all the prime numbers up to the number 9 would be 2, 3, 5, and 7. This simple algorithm is useful because it allows us
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

306 CHAPTER 10 (Yahoo web hosting) INFINITE DATA PATTERN Figure

Monday, November 26th, 2007

306 CHAPTER 10 INFINITE DATA PATTERN Figure 10-1. UML activity diagram for the Infinite Data pattern In Figure 10-1, a line splits the activity diagram into two pieces. The upper section is the client, or web browser. The lower section is the server side, or the HTTP server. For those not acquainted with UML activity diagrams, the starting point is the black dot in the upper-left corner, and the ending point is the black dot with a white circle around it on the right side. The first action after the starting point is a black bar indicating parallel actions. The client follows two routes because of the way that the Persistent Communications pattern is implemented using two communication streams. The route that starts with the action item Client defines stateis used to generate the structure that is sent to the server for further processing. The route that starts with the action box Query server is used to retrieve the results from the server that are then processed by the client. Let s focus our attention on the route that generates the structure that is sent to the server for further processing. The route starts with the action Client defines state that is used to transform the information on the client side into a structure. As an example, the information could be the values in an HTML form. The idea is to identify some information that when assembled as a single self-contained package represents a structure that a task on the server side operates on. The task is executed asynchronously and potentially generates some results. The next action items, State is converted into XML and XML is sent to server, represent conversion of the structure into an XML document that is sent to the server. The structure does not need to be formatted as an XML document, even though it is the preferred format. The information could be formatted by using some other text format such as XML-embedded Java- Script or JSON (http://www.json.org). As a side note, this pattern is conducive to using a format such as JSON because structured data, and not document-based data, is manipulated.
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

CHAPTER 10 INFINITE DATA PATTERN Persistent Communications (Web server application)

Monday, November 26th, 2007

CHAPTER 10 INFINITE DATA PATTERN Persistent Communications pattern is used because it is able to receive data asynchronously, which is a fundamental aspect of the Infinite Data pattern. The Infinite Data pattern is not related to any operations that define the basis of an HTML page. The Infinite Data pattern is not intended to be used as a replacement for the Content Chunking pattern, because the HTML content retrieved by the Content Chunking pattern is not processed. It is inserted into the HTML page. The results retrieved from the Infinite Data pattern are processed and transformed into content that is added to an HTML page. Architecture The nutshell description of the Infinite Data pattern is the building of a result set incrementally. Therefore, when implementing the Infinite Data pattern, the task executed must be able to generate results as the further results are being generated. When generating a result set, don t think of having to generate an individual result that is sent to the client immediately. It is acceptable to generate a set of results that are sent in batches to the client. Think of how search engines function. You create a query and are presented with an HTML page that probably contains a dozen results. To get the next dozen, another HTML page is loaded. The results are sent to you in batches. Some readers may say that with a database query it is not possible to generate a subset of results. A query generates a result set that is iterated. The argument is that the query that might take a long time cannot be subdivided into smaller queries. This is not entirely correct, as recently many databases and programming platforms such as .NET and Java have introduced APIs to execute asynchronous requests on a database. The asynchronous APIs will not be discussed because they are beyond the scope of this book. This chapter, though, does provide enough information on how the asynchronous APIs could be used. The aim of the Infinite Data pattern from the perspective of the client side is to send a task to the server, return control to the client, and then wait for the results to arrive from the server. From the server perspective, the Infinite Data pattern needs to implement the details of the Persistent Communications pattern. This means the server side has to implement concurrent programming techniques because requests and results are asynchronous of each other. The details of the Persistent Communications pattern require the implementation of threads, processes, or even an additional application server (for example, Java J2EE application server, COM+, or Zope). From an architectural perspective, an Infinite Data pattern implementation requires the execution of the following actions, which are not in sequential order: The client and server use the Persistent Communications pattern, which is responsible for sending and receiving data. The client creates a structure that contains the actions to be executed on the server. The server parses the actions and creates a task that is executed. The executed tasks process the information and if necessary generate a result(s). The client queries the server for a result. If a result is retrieved, it is processed on the client side. The actions, converted into a UML activity diagram, are illustrated in Figure 10-1.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.


Number
No Result
Number