US20090164613A1 - Method and system for improving client-servlet communication - Google Patents

Method and system for improving client-servlet communication Download PDF

Info

Publication number
US20090164613A1
US20090164613A1 US11/817,674 US81767407A US2009164613A1 US 20090164613 A1 US20090164613 A1 US 20090164613A1 US 81767407 A US81767407 A US 81767407A US 2009164613 A1 US2009164613 A1 US 2009164613A1
Authority
US
United States
Prior art keywords
servlet
request
web
client
browser
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Abandoned
Application number
US11/817,674
Inventor
Yannick Saillet
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
International Business Machines Corp
Original Assignee
International Business Machines Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by International Business Machines Corp filed Critical International Business Machines Corp
Publication of US20090164613A1 publication Critical patent/US20090164613A1/en
Abandoned legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/30Definitions, standards or architectural aspects of layered protocol stacks
    • H04L69/32Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e.g. the interfaces between the data link level and the physical level
    • H04L69/322Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions
    • H04L69/329Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions in the application layer [OSI layer 7]

Definitions

  • the present invention relates in general to Client-Server communication, and in particular to improving the Client-Servlet communication on a public network without changing the existing communication protocol and without changing the client.
  • Client-Server refers to a network application architecture which comprises client and servers communicating with each other via a communication protocol (e.g. HTTP).
  • a communication protocol e.g. HTTP
  • Web refers an information space in which the items of interest, referred to as resources, are identified by global identifiers called Uniform Resource Identifiers(URIs).
  • the Web is made up of three standards: The Uniform Resource Locator (URL), which specifies how each page of information is given a unique “address” at which it can be found; Hyper Text Transfer Protocol (HTTP), which specifies how the client and server send the information to each other, and Hyper Text Markup Language (HTML), a method of encoding the information so it can be displayed on a variety of devices.
  • URL Uniform Resource Locator
  • HTTP Hyper Text Transfer Protocol
  • HTML Hyper Text Markup Language
  • the Web works as follow: When a client's web-browser (e.g. Microsoft's Internet Explorer, Apple's Safari) is opened, it communicates on behalf of the client (or computer being used) using Hypertext Transfer Protocol (HTTP) and makes a web page request. Once the request is sent, the client's web-browser computer will wait for a hypertext data stream from the server. When the server gets the request, it looks for the requested file and, if present, sends it to the client's web-browser as requested.
  • HTTP Hypertext Transfer Protocol
  • Servlets are programs running on a server which wait for requests coming from a client's web-browser and generate a response to this request (for example as a dynamically generated Web-page).
  • Servlets perform the following functions:
  • the request is analyzed by the application server hosting the Servlets and is passed to the Servlet corresponding to the demanded URL.
  • the request is analyzed by the Servlet, eventual parameters are parsed and interpreted, and a document to return to the client's web-browser, is dynamically generated (the content of the document may depend on the eventual parameters passed by the client's web-browser in the request).
  • the generated document is received by the clients web-browser and is displayed or interpreted (in case it contains some executable scripts like JavaScript).
  • Servlets have transformed the internet by providing a powerful and scalable framework for presenting dynamic content: instead of publishing static documents whose content has to be updated regularly, Servlets allow the client's web-browser to append parameters to HTTP —requests and get current information based on its request. Without Servlets, it would be impossible to create interactive Web applications where the user interacts from his/her client's web-browser with the server.
  • Servlets have one limitation: after a request is received, they have no way to ask the client's web-browser for missing information.
  • Servlets can receive, with an incoming request, a list of parameters that can influence the action done on the server, or the information returned by the server. For example H you order something on the Internet, press the “submit” button will send a request containing the list of ordered items to the server. The server will work with this list (update a database, etc.) and usually generates a confirmation page listing all the chosen items.
  • a client's web-browser has to know exactly what information the Servlet needs.
  • a client's web-browser may need to provide more information than what is really needed by the Servlet.
  • Web World Wide Web
  • a method comprises providing a one way communication path that initiates a request by a client for retrieving information from a Servlet, and sending a response by the Servlet containing at least one return code specifying success or failure of the request, and including the result of the request if available. If the Servlet identifies missing information not included in the initial request, the method includes providing a complete response to automatically open an other communication path from the Servlet via the client's web-browser to the Servlet and providing the missing information to a Servlet by making use of the response functionality of the initial request.
  • the other communication path is supported by a further Servlet functionality component.
  • FIG. 1 shows the inventive two-way communication path of the present invention
  • FIG. 2 A shows a Client-Server architecture with an implementation of a preferred embodiment of the inventive two-way communication path
  • FIG. 2 B shows a sequence diagram which describes communication steps between client's web-browser, main Servlet and secondary Servlet in the given example.
  • FIG. 2 A shows a preferred embodiment of the present invention in a client-server architecture.
  • the conventional one-way communication path between client and Servlet remains unchanged if the initial request includes all information for retrieving the desired information.
  • the Servlet identifies missing information not included in the initial client's web-browser request for retrieving the information desired, the Servlet automatically opens another communication path for providing the missing information to the Servlet by making use of the HTTP-response functionality of said initial HTTP-request.
  • Another communication path is supported by a further Servlet functionality component.
  • the communication path comprises: generating a script—when executed at the client's web-browser retrieves the missing information and invokes the further Servlet functionality component—by the Servlet, appending the script to said HTTP-response indicating it as a partial response, sending the HTTP-response including the script to the client's web-browser, suspending execution of the initial HTTP-response by the Servlet until the missing information will be available, receiving the missing information by the further Servlet functionality component, wherein the missing information is contained in a new HTTP-request created by the script during its execution on the client's web-browser, providing the missing information to the Servlet, and continuing execution of the initial HTTP-response by the Servlet using the missing information for retrieving the rest of the said HTTP-response and providing the rest of the HTTP-response to the client's web-browser for displaying.
  • HTTP is the protocol used for the communication between a client's web-browser and a Web-server.
  • HTTP-protocol allows the client's web-browser to send a request to a web server (or an application server/a Servlet) to either send some information to the server (a POST request) or to get a document from the server (a GET request).
  • the server should always process it and return a response which contains a header containing a return code (indicating for example if the request could be successfully handled or not), and an eventual result document.
  • GET or POST type of request
  • the client's web-browser usually displays the document returned by the server, replacing the original page which contained the link of the element that produced the request, with the response from the server.
  • the server can also send regularly parts of the response document before the whole document generation is completed. This way the user can read the beginning of the document without having to wait for the whole document to be generated and transmitted.
  • the server usually has no way to send a request to the client's web-browser.
  • a system and method in accordance with the present invention uses the fact that the server can send a “partial document” to the client's web-browser before the whole response document is generated, and also uses the fact that this partial document can contain JavaScripts which can be executed by the client's web-browser before the whole document is completely transmitted.
  • JavaScript is a language that can be embedded in HTML pages and is interpreted by the client's web-browser.
  • a client's web-browser sends an HTTP-request to a main Servlet on an application server.
  • HTTP-request to a main Servlet on an application server.
  • the request it can provide some initial parameters required by the Servlet to process the request;
  • the main Servlet receives the request 10 , extracts and
  • the main Servlet notices that some information is missing and that this information has to be provided by the originator of the request 30 .
  • This information could be some missing data that the user has to enter, some system information about the client's web-browser itself or about the status of some other elements in the page displayed on the client's web-browser while the request is processed. It has to be information which can be retrieved with or without user interaction by executing a JavaScript on the client's web-browser;
  • the main Servlet suspends the processing of the request and the generation of the response and generates a JavaScript 40 which, when executed on the client's web-browser, does the following:
  • the main Servlet appends the JavaScript generated in the previous step to the partially generated response document, and sends the partial response to the client's web-browser 50 ;
  • the main Servlet suspends its execution by waiting until it can find the information it is asking for in the Web session or in the shared memory, under the key it has generated before 60 ;
  • the client's web-browser starts to display the partial document received from the main Servlet. If some content was already generated, it will be displayed.
  • the JavaScripts embedded in the response are executed;
  • the client's web-browser retrieves the missing information required by the main Servlet, encodes this information and the key, under which the information should be stored, into the URL of a secondary Servlet and sends a request to this secondary URL;
  • the secondary Servlet receives the request 62 containing in its parameters a key/value pair with the information to store in the session 64 (or the memory shared with the 1st Servlet). Then it returns a success code to the clients web-browser 65 . The client's web-browser can ignore the response of the secondary Servlet;
  • the main Servlet detects in the session (shared memory) that a value has been stored for the key it had generated. It extracts this value ( 70 ; which is the information it was missing to process the request), removes it from the session/shared memory and resumes the processing of the request;
  • the Servlets are implemented as Java Servlets.
  • the same method could be used for CGI script or any Servlet-similar programs hosted on a server and which provide dynamic content
  • scripts are implemented as Java Scripts.
  • scripts JavaScript
  • returned to the client's web-browser to retrieve the missing information could be in any language (Java, Visual Basic, etc. . . . ) that can be embedded in a Web page and executed on the fly by the client's web-browser.
  • Servlets which receive very low level information (such as mouse or key events) from the user, and do a complex processing of this information.
  • the client's web-browser simply sends the information about the mouse/key events produced by the user and does not know what the Servlet will do when sending the request or if it will do something with this information.
  • the Servlet interprets this information, and when it judges that an action has to be taken when a particular event occurs, it can ask the client's web-browser to provide more information about the event or some other elements on the client's web-browser side and do a dynamic processing of the event dependant on the information returned by the client's web-browser.
  • Servlets are used with complex processing paths.
  • the initial request contains enough information to start the processing.
  • the Servlet can take different execution paths depending on the parameters, or data retrieved by the server from backend systems (databases, etc. . . . ). If at some point a decision has to be taken by the user about how the processing should continue, the Servlet can ask the client's web browser to prompt the user for a decision. This decision can influence the further processing of the request, without interrupting the request.
  • the processing can run in a single transaction.
  • a secondary Servlet is additionally provided.
  • the secondary Servlets receives the new HTTP-request sent by the JavaScript, and stores the key value pair in the current HTTP-session object.
  • the JavaScript could send the request updating the HTTP-session to the main Servlet But in this case a second instance of the main Servlet would start (in parallel to the first instance which is still generating the response to the main request and wait for the missing value).
  • the HTTP-protocol could be replaced by other communication protocol that is characterized by a one way communication path initiating a request by said client's web-browser (3) for retrieving information from said Servlet (8), and by sending a response by said Servlet containing at least return code specifying success or failure of said request, and including the result of said request, if available.
  • the format of the document 13 returned by the server and displayed in the client's web-browser 3 need not be necessary an HTML document 13 .
  • All document types that can be displayed by a client's web-browser 3 and that can contain script elements being interpreted by the web-browser 3 during the rendering can be used.
  • the scripts 12 embedded in the document could be written in a language other than JavaScript.
  • the support of JavaScript 12 in client's web-browser 3 (or its standardized version ECMA Script) is standard.
  • any kind of script or plug-in that can be embedded in the document 13 to be rendered by the web-browser 3 , and that can be executed within the client's web-browser 3 , to retrieve information about other elements in the document 13 , or about the client's web-browser 3 or the user environments can be used. Examples could be: Visual Basic scripts, ActiveX components, Java applets, or native client's web-browser 3 plug-ins.
  • the HTTP-protocol could be replaced by other communication protocol that is characterized by a one way communication path initiating a request by said client's web-browser 3 for retrieving information from said Servlet 8 , and by sending a response by the Servlet 8 containing at least return code specifying success or failure of said request, and the result of said request, if available.
  • the server side 2 is preferably an application server 4 (e.g. a J2EE server like WebSphere, or Tomcat) with preferably a Servlet Container 6 .
  • application server 4 e.g. a J2EE server like WebSphere, or Tomcat
  • Application server 4 need not be a J2EE server. Any kind of server which is able to respond dynamically to HTTP requests coming from client's web-browsers 3 can be used. Examples of technologies that can be used in place of a J2EE application server are: Microsoft .NET, or a simple Web-server which can execute CGI-scripts to display dynamic content.
  • the Servlets 8 , 10 and Servlet Container 6 can be replaced by similar technologies such as ASP, PHP or CGI scripts.
  • the main Servlet 8 is the Servlet which implements the logic necessary to generate the document — 13 to send to the client's web-browser 3 in response to the initial request.
  • the main Servlet 8 receives the request, reads eventual parameters passed with the request and starts the generation of the document 13 to return it to client's the web-browser 3 .
  • the parameters passed with the request may influence the generation of the document 13 .
  • This invention does not depend on the logic used by the main Servlet 8 to generate the response document 13 .
  • the main Servlet 8 needs additional information that has not been provided by the client's web-browser 3 in the request (as parameter), but that could be easily retrieved by executing a JavaScript 12 on the client side 1 in the client's web-browser 3 .
  • the main Servlet 8 inserts a Javascript 12 in the document 13 it has started to generate.
  • This script 12 when executed by the client's web-browser 3 , retrieves the missing information, sends an HTTP-request to the secondary Servlet 10 , the request containing as parameter a key generated by the main Servlet a (key can be any unique string generated randomly) and the value retrieved in the previous step.
  • the main Servlet 8 flushes its buffer, so that the part of the response document 13 which has been generated until this points is immediately transmitted to the client's web-browser (2).
  • the communication channel to the web-browser 3 is not closed.
  • the header of the HTTP-response sent to the client's web-browser 3 indicates that the response uses a “Chunked Transfer Coding”, as defined in HTTP 1.1. This encoding means that the response will not come in one single piece but in a series of chunks, and that the client's web-browser 3 should wait for new content until the server closes the connection.
  • the client's web-browser 3 starts rendering the part of the document 13 which has been received so far and executes the embedded script 12 , while waiting for the rest of the document.
  • This script 12 retrieves the missing value and sends another HTTP-request to the secondary Servlet 10 .
  • This request contains as parameter the key and the value retrieved in the previous step (3).
  • the Secondary Servlet 10 receives the HTTP-request sent by the JavaScript 12 , decodes the key and value included in the parameters of the request, and store this key value pair in the current HTTP-session object(4).
  • the HTTP-session is an object which stores information about the current session between one client 1 and the server 2 .
  • the session object is passed to a Servlet each time it receives a request. If the same clients web-browser 3 sends HTTP-requests to several Servlets 8 contained in the same Servlet container 6 and in the same Web application, the same session object will be passed to the different Servlets 8 .
  • Servlets 8 can read write values in the session object (the values are stored under keys that can be used by later to retrieve the values). Using the HTTP-session is a common method in J2EE to pass values between different Servlets 8 .
  • the JavaScript 12 could send the request updating the HTTP-session to the main Servlet 8 .
  • a second instance of the main Servlet 8 would start (in parallel to the first instance which is still generating the response to the main request and wait for the missing value).
  • the main Servlet 8 would then need to test when receiving the request whether the request is asking for a document or whether the request provides additional information that have been requested by other instances of the Servlet treating document requests (main requests). Technically this would be done by testing the parameters passed with the request. If a specific parameter is contained in the request, the main Servlet 8 would know that it should update the HTTP-session with a key/value pair contained in other parameters of the request.
  • the main Servlet 8 should generate a response document 13 .
  • the main Servlet 8 would have 2 different logics depending on the parameters of the requests. This is exactly the same as having 2 different Servlets, each Servlet implementing a single logic.
  • the secondary Servlet 10 need not store the additional value passed by the second request (the request send by the JavaScript) in the HTTP-session to make it known by the main Servlet 8 .
  • Other methods could be storing the value in the System properties of the Java Virtual Machine of the Servlet container 6 , or using other shared memory mechanism (dependant on the technology used by the application server).
  • Another possibility would be to make the secondary Servlet 10 store this value in a file on a local disk of the server and make the main Servlet 8 read the same file.
  • the main Servlet 8 wakes up and continue the generation of the document 13 .
  • the document 13 can now be completely generated and the rest of the document 13 is transmitted to the browser (5)—during the last steps the main Servlet 8 has regular checked the content of the HTTP-session to see if the value was available. Each time it checked the session and the value was not available, it sleeps for a small amount of time and checked again.
  • the client's web-browser knows that the whole document 13 has been downloaded.
  • a Servlet 8 could need more than one additional information from the client's web-browser to proceed a request.
  • the retrieval of multiple missing information could be either done by repeating the steps described here several times during the processing of the request, or by generating one JavaScript 12 which retrieves and transmit all missing information to the secondary Servlet 10 in one HTTP-request.
  • the secondary Servlet 10 must then decode several key/value pairs from the secondary request sent by the JavaScript and update the HTTP-session accordingly.
  • the Servlet 8 could request additional information from the client's web-browser 3 , after the client's web-browser 3 has submitted its initial request, and during the processing of the request. The processing of the request did not have to be aborted and started from the beginning again as it would have to be without this invention.
  • Both main 8 and secondary 10 Servlet are separately normal Servlets which receive an HTTP-request and return one single response to the originator of the request, as defined in the HTTP protocol. The protocol is not modified. All communication between the client's web-browser 3 and the server 2 are driven by the client's web-browser (as foreseen by the HTTP-protocol).
  • main Servlet 8 which receives a request from the client's web-browser 3 and generates some content in a way that is dependant on some properties of the client's web-browser 3 which sent the request. It is further assumed, that the main Servlet 8 needs to know the width of the client's web-browser window that sent the request, and that this information was not included in the initial request sent to the main Servlet 8 .
  • the width of the client's web-browser window is a property that can be easily asked by executing the JavaScript expression “window.outerWidth” in the client's web-browser 3 .
  • the code source of the main 8 and secondary 10 Servlets for this example is in the appendix at the end of this document. Note that the secondary Servlet is independent from the logic of the primary Servlet and can be reused or shared by several “main” Servlets implementing a different logic.
  • the secondary Servlet 10 receives the request containing in its parameters a key/value pair with the information to store in the session (or the memory shared with the 1st Servlet). Then it returns a success code to the web-browser 3 . The web-browser 3 can ignore the response of the secondary Servlet 10 .
  • the main Servlet 8 detects in the session (shared memory) that a value has been stored for the key it had generated. It extracts this value (which is the information it was missing to process the request), removes it from the session/shared memory and resumes the processing of the request.
  • FIG. 2 B describes the activities and communication that takes place between the client's web-browser and the 2 Servlets in this example according to present invention.
  • the client's web-browser sends the initial request to the main Servlet 8 by sending an HTTP GET command (alternative: a POST command could also be used) to the server 2 , requesting the URL of the main Servlet 8 .
  • HTTP GET command alternative: a POST command could also be used
  • This request could also contain additional parameters that could be used by the main Servlet 8 during the generation of the response document. In this example, there is no parameter.
  • the main Servlet 8 starts the generation of the response document by writing the beginning of the document until the point where it need the missing information (the width of the client's web-browser):
  • the main Servlet 8 needs the missing information. It generates a unique key, that will be used to store and find the missing value in the HTTP session, after the client's web-browser has sent it to the secondary Servlet 10 , and appends to the content generated so far a JavaScript, which, when executed by the client's web-browser, will retrieve the value and sends it with the key to the secondary Servlet 10 .
  • Line 2 retrieves the width of the web-browser 3 window, the following lines let the web-browser 3 open an HTTP-request to the secondary Servlet 10 , passing as parameter the key (here the random value of the key is key — 112108) and the retrieved value (here contained in the variable “value”)
  • the partial document (the content generated so far and the script retrieved the missing value) is sent to the client's web-browser 3 , by flushing the buffer of the main Servlet 8 .
  • the application server changes the encoding of the HTTP response to “chunked”, which indicates the client's web-browser 3 that the content will be transferred in several chunked pieces.
  • FIG. 2 shows the content of the document transferred to the clients web-browser at this point.
  • the main Servlet 8 suspends its execution until it finds in the HTTP-session a value stored under the key it has generated in step (2). Technically it suspends its execution and checks at regular interval if the value is available or not. Once the value is found, it resumes its execution.
  • the client's web-browser 3 has received the 1st chunk of the document sent by the main Servlet 8 . It displays the displayable content contained in the document so far and executes the JavaScript embedded in it. Note that the JavaScript does not affect the content of the document at all.
  • the client's web-browser 3 retrieves the width of its window (here 454 pixels) and sends an HTTP GET request to the secondary Servlet 10 .
  • This request contains as parameter the key generated before (key — 112108) and the retrieved value (454).
  • the secondary Servlet 10 receives this request, decode the key and value out of its parameter and place in the HTTP-session the value (454) under the key (key — 112108). Then it immediately returns a success code (HTTP code 200)(8),
  • the main Servlet 8 which checked at regular interval the HTTP session for a value stored under the key “key — 112108”, finds this value. It removes it from the session and resume the generation of the document, using the value it has retrieved. (In this example, the value is simply written in the text. In a more complex example it could be used to do a more complex layout of the document).
  • FIG. 1 For more detailed execution diagrams, see FIG. 1 .
  • This methods generates and transmit a JavaScript to be interpreted * by the client’s web-browser.
  • This JavaScript retrieves the missing value * by executing a JavaScript expression given as parameter, * and sends a request to the secondary Servlet that will store * the retrieved value in the HTTP session, to that it is accessible * for the main Servlet * Note that this method will block and suspend the main Servlet, until * the missing value has been returned by the client’s web-browser.
  • Source 2 Secondary servlet Import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** * Secondary Servlet updating the HTTP session with key/value pairs.
  • the key/value pairs to store are contained in the incoming requests * under the keys “key” and “value”.
  • HttpServlet implements Servlet ⁇ /** * @see javax.servlet.http.Httpservlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public void doGet(HttpservletRequest req, HttpServletResponse resp) throws ServletException, IOException ⁇ // Extracts from the request coming from the browser the key/value // pair to store in the HTTP session

Abstract

A method comprises providing a one way communication path that initiates a request by a client for retrieving information from a Servlet, and sending a response by the Servlet containing at least one return code specifying success or failure of the request, and including the result of the request if available. If the Servlet identifies missing information not included in the initial request, the method includes providing a complete response to automatically open an other communication path from the Servlet via the client's web-browser to the Servlet and providing the missing information to a Servlet by making use of the response functionality of the initial request. The other communication path is supported by a further Servlet functionality component.

Description

    CROSS-REFERENCE TO RELATED APPLICATIONS
  • This application claims the right to foreign priority benefits under Title 35, United States Code Section 119 to European Patent Application No. 05108239.4, filed Sep. 8, 2005. This application also claims the benefit of PCT Patent Publication No. WO/2007/028670 A1, filed Jul. 26, 2006 as International Patent Application No. PCT/EP2006/064658, all of which is incorporated herein by reference.
  • FIELD OF THE PRESENT INVENTION
  • The present invention relates in general to Client-Server communication, and in particular to improving the Client-Servlet communication on a public network without changing the existing communication protocol and without changing the client.
  • BACKGROUND OF THE PRESENT INVENTION
  • The term “Client-Server” refers to a network application architecture which comprises client and servers communicating with each other via a communication protocol (e.g. HTTP).
  • Web refers an information space in which the items of interest, referred to as resources, are identified by global identifiers called Uniform Resource Identifiers(URIs). The Web is made up of three standards: The Uniform Resource Locator (URL), which specifies how each page of information is given a unique “address” at which it can be found; Hyper Text Transfer Protocol (HTTP), which specifies how the client and server send the information to each other, and Hyper Text Markup Language (HTML), a method of encoding the information so it can be displayed on a variety of devices.
  • The Web works as follow: When a client's web-browser (e.g. Microsoft's Internet Explorer, Apple's Safari) is opened, it communicates on behalf of the client (or computer being used) using Hypertext Transfer Protocol (HTTP) and makes a web page request. Once the request is sent, the client's web-browser computer will wait for a hypertext data stream from the server. When the server gets the request, it looks for the requested file and, if present, sends it to the client's web-browser as requested.
  • Servlets are programs running on a server which wait for requests coming from a client's web-browser and generate a response to this request (for example as a dynamically generated Web-page).
  • Conventionally, Servlets perform the following functions:
      • A client's web-browser sends an HTTP-request to the Servlet by invoking its URL. The client's web-browser is not necessarily aware that it is invoking a Servlet. Invoking a Servlet is like loading any other web page, the difference being that parameters can be passed in the request to the Servlet and that the response sent back by the server is not a static document but is dynamically generated.)
  • The request is analyzed by the application server hosting the Servlets and is passed to the Servlet corresponding to the demanded URL.
  • The request is analyzed by the Servlet, eventual parameters are parsed and interpreted, and a document to return to the client's web-browser, is dynamically generated (the content of the document may depend on the eventual parameters passed by the client's web-browser in the request).
  • The generated document is received by the clients web-browser and is displayed or interpreted (in case it contains some executable scripts like JavaScript).
  • Servlets have transformed the internet by providing a powerful and scalable framework for presenting dynamic content: instead of publishing static documents whose content has to be updated regularly, Servlets allow the client's web-browser to append parameters to HTTP —requests and get current information based on its request. Without Servlets, it would be impossible to create interactive Web applications where the user interacts from his/her client's web-browser with the server.
  • However Servlets have one limitation: after a request is received, they have no way to ask the client's web-browser for missing information.
  • Servlets can receive, with an incoming request, a list of parameters that can influence the action done on the server, or the information returned by the server. For example H you order something on the Internet, press the “submit” button will send a request containing the list of ordered items to the server. The server will work with this list (update a database, etc.) and usually generates a confirmation page listing all the chosen items.
  • But with traditional Servlets, all parameters necessary to treat the request on the server have to be contained in the initial request sent by the client's web-browser: if the Servlet notices during the processing of a request that some additional information is not provided by the client's web-browser in the initial request, there is no way to suspend the processing, ask the client's web-browser for the missing information and resume the processing from the point where it was interrupted. This limits the application area of Servlets:
  • A client's web-browser has to know exactly what information the Servlet needs.
  • In its request, a client's web-browser may need to provide more information than what is really needed by the Servlet.
  • Traditional Servlets cannot handle unexpected situations requiring more information than provided by the client's web-browser request. It the request does not contain all necessary information, the traditional way to handle the problem is to stop the processing, return a Web page to the client's web-browser which replaces the original page and displays an error message or display a new page asking for the missing information and invoking the same or another Servlet with the new information.
  • This is not a very good method to handle missing information, because it may not be simple to slop a request processing in one Servlet invocation, and continue the transaction in another Servlet invocation. Also, it may confuse the user, since quite often, the same page is displayed again with a small annotation informing the user about what information is missing—this is problematic from a usability standpoint.
  • It is desirable to provide a method and system for improving the Client-Servlet communication in the World Wide Web (Web) without changing the existing communication protocol and without changing the client, more particularly, it is desirable to improve the flexibility and interactivity of Servlets for retrieving desired information not included in the initial clients web browser. The present invention addresses such need.
  • SUMMARY OF THE PRESENT INVENTION
  • A method comprises providing a one way communication path that initiates a request by a client for retrieving information from a Servlet, and sending a response by the Servlet containing at least one return code specifying success or failure of the request, and including the result of the request if available. If the Servlet identifies missing information not included in the initial request, the method includes providing a complete response to automatically open an other communication path from the Servlet via the client's web-browser to the Servlet and providing the missing information to a Servlet by making use of the response functionality of the initial request. The other communication path is supported by a further Servlet functionality component.
  • BRIEF DESCRIPTION OF THE DRAWINGS
  • FIG. 1 shows the inventive two-way communication path of the present invention,
  • FIG. 2 A shows a Client-Server architecture with an implementation of a preferred embodiment of the inventive two-way communication path, and
  • FIG. 2 B shows a sequence diagram which describes communication steps between client's web-browser, main Servlet and secondary Servlet in the given example.
  • FIG. 2 A shows a preferred embodiment of the present invention in a client-server architecture.
  • DETAILED DESCRIPTION
  • The following description is presented to enable one of ordinary skill in the art to make and use the embodiment and is provided in the context of a patent application and its requirements. Various modifications to the implementations and the generic principles and features described herein will be readily apparent to those skilled in the art. Thus, the present embodiment is not intended to be limited to the implementations shown, but is to be accorded the widest scope consistent with the principles and features described herein.
  • The conventional one-way communication path between client and Servlet remains unchanged if the initial request includes all information for retrieving the desired information. However in the case the Servlet identifies missing information not included in the initial client's web-browser request for retrieving the information desired, the Servlet automatically opens another communication path for providing the missing information to the Servlet by making use of the HTTP-response functionality of said initial HTTP-request. Another communication path is supported by a further Servlet functionality component. The communication path comprises: generating a script—when executed at the client's web-browser retrieves the missing information and invokes the further Servlet functionality component—by the Servlet, appending the script to said HTTP-response indicating it as a partial response, sending the HTTP-response including the script to the client's web-browser, suspending execution of the initial HTTP-response by the Servlet until the missing information will be available, receiving the missing information by the further Servlet functionality component, wherein the missing information is contained in a new HTTP-request created by the script during its execution on the client's web-browser, providing the missing information to the Servlet, and continuing execution of the initial HTTP-response by the Servlet using the missing information for retrieving the rest of the said HTTP-response and providing the rest of the HTTP-response to the client's web-browser for displaying.
  • The reason why Servlets have the limitation described in the prior art, stems from the way the HTTP protocol and Web browsers/servers are designed:
  • HTTP is the protocol used for the communication between a client's web-browser and a Web-server.
  • Usually the HTTP-protocol allows the client's web-browser to send a request to a web server (or an application server/a Servlet) to either send some information to the server (a POST request) or to get a document from the server (a GET request).
  • Independent of the type of request (GET or POST) sent by the client's web-browser, the server should always process it and return a response which contains a header containing a return code (indicating for example if the request could be successfully handled or not), and an eventual result document. When the request Was successful, the client's web-browser usually displays the document returned by the server, replacing the original page which contained the link of the element that produced the request, with the response from the server.
  • If the request is long-running, the server can also send regularly parts of the response document before the whole document generation is completed. This way the user can read the beginning of the document without having to wait for the whole document to be generated and transmitted.
  • This is a one-way communication: the protocol only foresees a communication initiated by the client's web-browser. The server usually has no way to send a request to the client's web-browser.
  • To overcome this limitation, a system and method in accordance with the present invention uses the fact that the server can send a “partial document” to the client's web-browser before the whole response document is generated, and also uses the fact that this partial document can contain JavaScripts which can be executed by the client's web-browser before the whole document is completely transmitted. JavaScript is a language that can be embedded in HTML pages and is interpreted by the client's web-browser.
  • With this invention a two-way communication between web-client and web-server is provided which works as follows (see FIG. 1):
  • a client's web-browser sends an HTTP-request to a main Servlet on an application server. With the request it can provide some initial parameters required by the Servlet to process the request;
  • the main Servlet receives the request 10, extracts and
  • interprets the eventual parameters and starts to process the request by doing some actions on the server side, generating a response document 20;
  • (Up to this point, this is how prior art Servlets work), during the processing of the request, the main Servlet notices that some information is missing and that this information has to be provided by the originator of the request 30. This information could be some missing data that the user has to enter, some system information about the client's web-browser itself or about the status of some other elements in the page displayed on the client's web-browser while the request is processed. It has to be information which can be retrieved with or without user interaction by executing a JavaScript on the client's web-browser;
  • the main Servlet suspends the processing of the request and the generation of the response and generates a JavaScript 40 which, when executed on the client's web-browser, does the following:
  • it retrieves (or asks the user for) the missing information;
  • it invokes a secondary Servlet passing the additionally retrieved information as a parameter and a key generated by the Servlet requesting the information;
  • the main Servlet appends the JavaScript generated in the previous step to the partially generated response document, and sends the partial response to the client's web-browser 50;
  • the main Servlet suspends its execution by waiting until it can find the information it is asking for in the Web session or in the shared memory, under the key it has generated before 60;
  • meanwhile the client's web-browser starts to display the partial document received from the main Servlet. If some content was already generated, it will be displayed. The JavaScripts embedded in the response are executed;
  • while executing the JavaScript embedded in the partial response document, the client's web-browser retrieves the missing information required by the main Servlet, encodes this information and the key, under which the information should be stored, into the URL of a secondary Servlet and sends a request to this secondary URL;
  • it is important to note that the result of this 2nd request—while the request to the main Servlet is still running—should not replace the current document displayed by the clients web-browser and interrupt the 1st request. This can be achieved by redirecting the result of the second request to a separate frame, or to a specific element of the page (image, embedded frame), or by using the JavaScript API to open programmatically an HTTP request;
  • the secondary Servlet receives the request 62 containing in its parameters a key/value pair with the information to store in the session 64 (or the memory shared with the 1st Servlet). Then it returns a success code to the clients web-browser 65. The client's web-browser can ignore the response of the secondary Servlet;
  • the main Servlet detects in the session (shared memory) that a value has been stored for the key it had generated. It extracts this value (70; which is the information it was missing to process the request), removes it from the session/shared memory and resumes the processing of the request;
  • the processing continues the rest of the response document is generated. If it appears that even more information is missing later on during the processing of the request, the last steps can be repeated, to sequentially ask the user for more Information 80; and
  • finally the request is completed and the client's web-browser receives and displays the full response document 80.
  • In a preferred embodiment of the present invention, the Servlets are implemented as Java Servlets. However the same method could be used for CGI script or any Servlet-similar programs hosted on a server and which provide dynamic content
  • in response to HTTP requests.
  • In a further preferred embodiment of the present invention, the scripts are implemented as Java Scripts. However scripts (JavaScript), returned to the client's web-browser to retrieve the missing information, could be in any language (Java, Visual Basic, etc. . . . ) that can be embedded in a Web page and executed on the fly by the client's web-browser.
  • In a further embodiment of the present invention, it is possible to create generic Servlets which receive very low level information (such as mouse or key events) from the user, and do a complex processing of this information. The client's web-browser simply sends the information about the mouse/key events produced by the user and does not know what the Servlet will do when sending the request or if it will do something with this information. The Servlet interprets this information, and when it judges that an action has to be taken when a particular event occurs, it can ask the client's web-browser to provide more information about the event or some other elements on the client's web-browser side and do a dynamic processing of the event dependant on the information returned by the client's web-browser.
  • In another further embodiment of the present invention, Servlets are used with complex processing paths. The initial request contains enough information to start the processing. During the processing, the Servlet can take different execution paths depending on the parameters, or data retrieved by the server from backend systems (databases, etc. . . . ). If at some point a decision has to be taken by the user about how the processing should continue, the Servlet can ask the client's web browser to prompt the user for a decision. This decision can influence the further processing of the request, without interrupting the request. The processing can run in a single transaction.
  • In a further preferred embodiment of the present invention, a secondary Servlet is additionally provided. The secondary Servlets receives the new HTTP-request sent by the JavaScript, and stores the key value pair in the current HTTP-session object.
  • In a further embodiment of the present invention, instead of using a secondary Servlet, the JavaScript could send the request updating the HTTP-session to the main Servlet But in this case a second instance of the main Servlet would start (in parallel to the first instance which is still generating the response to the main request and wait for the missing value).
  • In further embodiment of the present invention the HTTP-protocol could be replaced by other communication protocol that is characterized by a one way communication path initiating a request by said client's web-browser (3) for retrieving information from said Servlet (8), and by sending a response by said Servlet containing at least return code specifying success or failure of said request, and including the result of said request, if available.
  • In the following preferred embodiments of the present invention will be described in greater detail by a way of example only making reference to the drawing in which:
  • Alternatively the format of the document 13 returned by the server and displayed in the client's web-browser 3 need not be necessary an HTML document 13. All document types that can be displayed by a client's web-browser 3 and that can contain script elements being interpreted by the web-browser 3 during the rendering can be used. Example of documents that could be used: XML, XHTML, SVG (Scalable Vector Graphics), XUL (XML User Interface Language), etc. (especially all kind of XML documents). The scripts 12 embedded in the document could be written in a language other than JavaScript. The support of JavaScript 12 in client's web-browser 3 (or its standardized version ECMA Script) is standard. However any kind of script or plug-in that can be embedded in the document 13 to be rendered by the web-browser 3, and that can be executed within the client's web-browser 3, to retrieve information about other elements in the document 13, or about the client's web-browser 3 or the user environments can be used. Examples could be: Visual Basic scripts, ActiveX components, Java applets, or native client's web-browser 3 plug-ins. The HTTP-protocol could be replaced by other communication protocol that is characterized by a one way communication path initiating a request by said client's web-browser 3 for retrieving information from said Servlet 8, and by sending a response by the Servlet 8 containing at least return code specifying success or failure of said request, and the result of said request, if available.
  • The server side 2 is preferably an application server 4 (e.g. a J2EE server like WebSphere, or Tomcat) with preferably a Servlet Container 6. Two Servlets—the main Servlet 8 and the secondary Servlet 10—are installed in this application server 4 in the preferred embodiment of the present invention.
  • Application server 4 need not be a J2EE server. Any kind of server which is able to respond dynamically to HTTP requests coming from client's web-browsers 3 can be used. Examples of technologies that can be used in place of a J2EE application server are: Microsoft .NET, or a simple Web-server which can execute CGI-scripts to display dynamic content. The Servlets 8, 10 and Servlet Container 6 can be replaced by similar technologies such as ASP, PHP or CGI scripts.
  • A system and method in accordance with the present invention when implemented in its embodiment—operates as follows (see arrows in FIG. 2 A):
  • On the client side 1 the client's web-browser 3 sends a request to the main Servlet (1). The main Servlet 8 is the Servlet which implements the logic necessary to generate the document —13 to send to the client's web-browser 3 in response to the initial request. The main Servlet 8 receives the request, reads eventual parameters passed with the request and starts the generation of the document 13 to return it to client's the web-browser 3. The parameters passed with the request may influence the generation of the document 13. This invention does not depend on the logic used by the main Servlet 8 to generate the response document 13.
  • At some point during the generation of the response, the main Servlet 8 needs additional information that has not been provided by the client's web-browser 3 in the request (as parameter), but that could be easily retrieved by executing a JavaScript 12 on the client side 1 in the client's web-browser 3.
  • The main Servlet 8 inserts a Javascript 12 in the document 13 it has started to generate. This script 12, when executed by the client's web-browser 3, retrieves the missing information, sends an HTTP-request to the secondary Servlet 10, the request containing as parameter a key generated by the main Servlet a (key can be any unique string generated randomly) and the value retrieved in the previous step.
  • Once the script 12 has been generated and inserted in the partial response, the main Servlet 8 flushes its buffer, so that the part of the response document 13 which has been generated until this points is immediately transmitted to the client's web-browser (2). The communication channel to the web-browser 3 is not closed. The header of the HTTP-response sent to the client's web-browser 3 indicates that the response uses a “Chunked Transfer Coding”, as defined in HTTP 1.1. This encoding means that the response will not come in one single piece but in a series of chunks, and that the client's web-browser 3 should wait for new content until the server closes the connection.
  • Once the partially generated document 13 (the first chunk containing the beginning of the document and the JavaScript 12 retrieving the missing information), is transmitted to the client's web-browser 3, the client's web-browser 3 starts rendering the part of the document 13 which has been received so far and executes the embedded script 12, while waiting for the rest of the document.
  • The execution of this script 12 retrieves the missing value and sends another HTTP-request to the secondary Servlet 10. This request contains as parameter the key and the value retrieved in the previous step (3).
  • The ability to send additional HTTP-requests to different URL while the response of a 1st HTTP request is being loaded is a normal behavior for web-browsers 3. Without this capability, client's web-browsers 3 would not be able for instance to display images contained in the beginning of a long document being loaded, before the whole document is completely loaded.
  • The Secondary Servlet 10 receives the HTTP-request sent by the JavaScript 12, decodes the key and value included in the parameters of the request, and store this key value pair in the current HTTP-session object(4). The HTTP-session is an object which stores information about the current session between one client 1 and the server 2. The session object is passed to a Servlet each time it receives a request. If the same clients web-browser 3 sends HTTP-requests to several Servlets 8 contained in the same Servlet container 6 and in the same Web application, the same session object will be passed to the different Servlets 8. Servlets 8 can read write values in the session object (the values are stored under keys that can be used by later to retrieve the values). Using the HTTP-session is a common method in J2EE to pass values between different Servlets 8.
  • Instead of using a secondary Servlet 10, the JavaScript 12 could send the request updating the HTTP-session to the main Servlet 8. But in this case a second instance of the main Servlet 8 would start (in parallel to the first instance which is still generating the response to the main request and wait for the missing value). The main Servlet 8 would then need to test when receiving the request whether the request is asking for a document or whether the request provides additional information that have been requested by other instances of the Servlet treating document requests (main requests). Technically this would be done by testing the parameters passed with the request. If a specific parameter is contained in the request, the main Servlet 8 would know that it should update the HTTP-session with a key/value pair contained in other parameters of the request. In any other case, the main Servlet 8 should generate a response document 13. By doing this, the main Servlet 8 would have 2 different logics depending on the parameters of the requests. This is exactly the same as having 2 different Servlets, each Servlet implementing a single logic.
  • The secondary Servlet 10 need not store the additional value passed by the second request (the request send by the JavaScript) in the HTTP-session to make it known by the main Servlet 8. Other methods could be storing the value in the System properties of the Java Virtual Machine of the Servlet container 6, or using other shared memory mechanism (dependant on the technology used by the application server). Another possibility would be to make the secondary Servlet 10 store this value in a file on a local disk of the server and make the main Servlet 8 read the same file.
  • Once the requested value is found by the main Servlet 8 in the shared memory (in the HTTP session), the main Servlet 8 wakes up and continue the generation of the document 13. With the missing information, the document 13 can now be completely generated and the rest of the document 13 is transmitted to the browser (5)—during the last steps the main Servlet 8 has regular checked the content of the HTTP-session to see if the value was available. Each time it checked the session and the value was not available, it sleeps for a small amount of time and checked again.
  • Once the Servlet 8 closes the connection with the web-browser 3 (this is done automatically when the doGet( . . . ) or doPost( . . . ) method of the Servlet returns), the client's web-browser knows that the whole document 13 has been downloaded.
  • A Servlet 8 could need more than one additional information from the client's web-browser to proceed a request. The retrieval of multiple missing information could be either done by repeating the steps described here several times during the processing of the request, or by generating one JavaScript 12 which retrieves and transmit all missing information to the secondary Servlet 10 in one HTTP-request. The secondary Servlet 10 must then decode several key/value pairs from the secondary request sent by the JavaScript and update the HTTP-session accordingly.
  • By using this method, the Servlet 8 could request additional information from the client's web-browser 3, after the client's web-browser 3 has submitted its initial request, and during the processing of the request. The processing of the request did not have to be aborted and started from the beginning again as it would have to be without this invention.
  • No modifications are required in the web-browser 3 and in the application server 4. Both main 8 and secondary 10 Servlet are separately normal Servlets which receive an HTTP-request and return one single response to the originator of the request, as defined in the HTTP protocol. The protocol is not modified. All communication between the client's web-browser 3 and the server 2 are driven by the client's web-browser (as foreseen by the HTTP-protocol).
  • The collaboration between the two Servlets 8, 10 and the fact that a Servlet can remote control the client's web-browser 3 by chunking its response document and embed JavaScript commands in it makes the bi-directional communication between server and client's web-browser possible.
  • In the following a simple example shows how the present invention practically works (see FIG. 2 B).
  • It is assumed that there is a main Servlet 8 which receives a request from the client's web-browser 3 and generates some content in a way that is dependant on some properties of the client's web-browser 3 which sent the request. It is further assumed, that the main Servlet 8 needs to know the width of the client's web-browser window that sent the request, and that this information was not included in the initial request sent to the main Servlet 8.
  • The width of the client's web-browser window is a property that can be easily asked by executing the JavaScript expression “window.outerWidth” in the client's web-browser 3.
  • The code source of the main 8 and secondary 10 Servlets for this example is in the appendix at the end of this document. Note that the secondary Servlet is independent from the logic of the primary Servlet and can be reused or shared by several “main” Servlets implementing a different logic.
  • It is important to note that the result of this second request—while the request to the main Servlet is still running—should not replace the current document displayed by the client's web-browser and interrupt the 1st request. This can be achieved by redirecting the result of the second request to a separate frame, or to a specific element of the page (image, embedded frame), or by using the JavaScript API to open programmatically an HTTP-request.
  • The secondary Servlet 10 receives the request containing in its parameters a key/value pair with the information to store in the session (or the memory shared with the 1st Servlet). Then it returns a success code to the web-browser 3. The web-browser 3 can ignore the response of the secondary Servlet 10.
  • The main Servlet 8 detects in the session (shared memory) that a value has been stored for the key it had generated. It extracts this value (which is the information it was missing to process the request), removes it from the session/shared memory and resumes the processing of the request.
  • The processing continues the rest of the response document is generated. If it appears that even more information is missing later on during the processing of the request, the last steps can be repeated, to sequentially ask the user for more information.
  • Finally the request is completed and the client's web-browser 3 receives and displays the full response document.
  • FIG. 2 B describes the activities and communication that takes place between the client's web-browser and the 2 Servlets in this example according to present invention.
  • (1) The client's web-browser sends the initial request to the main Servlet 8 by sending an HTTP GET command (alternative: a POST command could also be used) to the server 2, requesting the URL of the main Servlet 8. This request could also contain additional parameters that could be used by the main Servlet 8 during the generation of the response document. In this example, there is no parameter.
  • (2) The main Servlet 8 starts the generation of the response document by writing the beginning of the document until the point where it need the missing information (the width of the client's web-browser):
  • <html>
     <head>
     </head>
     <body>
  • Some content produced by the Servlet before the missing value is asked<p>,
  • At this point, to write the rest of the document, the main Servlet 8 needs the missing information. It generates a unique key, that will be used to store and find the missing value in the HTTP session, after the client's web-browser has sent it to the secondary Servlet 10, and appends to the content generated so far a JavaScript, which, when executed by the client's web-browser, will retrieve the value and sends it with the key to the secondary Servlet 10.
  • Here is how the script would look like in this example:
  • Line 2 retrieves the width of the web-browser 3 window, the following lines let the web-browser 3 open an HTTP-request to the secondary Servlet 10, passing as parameter the key (here the random value of the key is key112108) and the retrieved value (here contained in the variable “value”)
  • <script language=“JavaScript”>
    var value = window.outerWidth;
    var httpReq = new XMLHttpRequest( );
    httpReq.open(“GET”,“SecondaryServlet?key=
    key_112108&value=”+value,true);
    httpReq.send(null);
    </script>
  • (3) The partial document (the content generated so far and the script retrieved the missing value) is sent to the client's web-browser 3, by flushing the buffer of the main Servlet 8. When doing this, the application server changes the encoding of the HTTP response to “chunked”, which indicates the client's web-browser 3 that the content will be transferred in several chunked pieces. FIG. 2 shows the content of the document transferred to the clients web-browser at this point.
  • (4) The main Servlet 8 suspends its execution until it finds in the HTTP-session a value stored under the key it has generated in step (2). Technically it suspends its execution and checks at regular interval if the value is available or not. Once the value is found, it resumes its execution.
  • (5) Meanwhile the client's web-browser 3 has received the 1st chunk of the document sent by the main Servlet 8. It displays the displayable content contained in the document so far and executes the JavaScript embedded in it. Note that the JavaScript does not affect the content of the document at all.
  • (6) When executing the JavaScript, the client's web-browser 3 retrieves the width of its window (here 454 pixels) and sends an HTTP GET request to the secondary Servlet 10. (Alternative, a POST request could also be used). This request contains as parameter the key generated before (key112108) and the retrieved value (454).
  • GET SecondaryServlet?key=key112108&value=454,
  • (7) The secondary Servlet 10 receives this request, decode the key and value out of its parameter and place in the HTTP-session the value (454) under the key (key112108). Then it immediately returns a success code (HTTP code 200)(8),
  • (8) The main Servlet 8, which checked at regular interval the HTTP session for a value stored under the key “key112108”, finds this value. It removes it from the session and resume the generation of the document, using the value it has retrieved. (In this example, the value is simply written in the text. In a more complex example it could be used to do a more complex layout of the document).
  • 2nd chunked part of the document sent to the client's web-browser 3:
  • Finish the generation of the page: Width=454
  • </body>
    </html>
  • (9) The 2nd chunked part of the document is sent to the client's web-browser, and the main Servlet 8 closes the communication channel with client's web-browser 3, indicating that no more content will follow.
  • (10) The client's web-browser 3 displays the rest of the document.
  • For more detailed execution diagrams, see FIG. 1.
  • For the complete source code of this example see the appendix at this end of this document.
  • APPENDIX
    Source 1: Main Servlet
      import java.io.*;
      import javax.Servlet.*;
      import javax.Servlet.http.*;
      public class MainServlet extends HttpServlet implements Servlet {
    /**
     * URL of the secondary Servlet storing the requested key/value pairs
     * in the HTTP session
     */
    private final static String SECONDARY_SERVLET_URL = “SecondaryServlet”;
    /**
    * @see javax.Servlet.http.HttpServlet#void
     (javax.Servlet.http.HttpServletRequest,
     javax.Servlet.http.HttpServletResponse)
    */
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
     resp.setContentType(“text/html; charset=ISO-8859-4”);
     HttpSession session = req.getSession( );
     PrintWriter out = resp.getWriter( );
     out.println(“<html>”);
     out.println(“ <head>”);
     out.println(“ </head>”);
     out.println(“ <body>”);
     // Starts the generation of the response
     out.println(
      “ Some content produced by the Servlet before the missing value is asked<p>”);
     // (...)
     // at some point during the processing at the answer,
     // the Servlet notlces that some information are missing
     // Suspends the generation of the response.
     // Asks the client's web-browser's to retrieve the missing value and send it to
     // the server through the secondary Servlet
     // The 3rd parameter is the JavaScript expression retrieving
     // the value when executed in the browser.
     // In this example we ask the client's web-browser for the width of the
     browser window
     Object value = requestValue(req, resp, “window.outerWidth;”);
     // When this method returns, the local variable “value” contains the
     requested value
     // Continue the generation of the response
     // (...)
     out.println(“Finish the generation of the page: Width=” + value);
     out.println(“  </body>”);
     out.println(“</html>”);
    }
    /**
     * Generates a unique key that can be used to store the missing value in
     the Web session
     */
    private String generateKey( ) {
     return “key_” + System.currentTimeMillis( );
    }
    /**
     * Requests the client’s web-browser to provide the Servlet a missing value.
     * This methods generates and transmit a JavaScript to be interpreted
     * by the client’s web-browser. This JavaScript retrieves the missing value
     * by executing a JavaScript expression given as parameter,
     * and sends a request to the secondary Servlet that will store
     * the retrieved value in the HTTP session, to that it is accessible
     * for the main Servlet
     * Note that this method will block and suspend the main Servlet, until
     * the missing value has been returned by the client’s web-browser.
     *
     * @param req The main HTTP request sent by the client’s web-browser to this main Servlet
     * @param resp The HTTP response used by this Servlet to respond to the request
     * @param JavaScriptExpression The JavaScript expression, which when executed
     * in the client’s web-browser, returns the missing information needed by this Servlet
     * @return The missing value returned by the client’s web-browser.
     */
    private Object requestValue(
     HttpServletRequest req,
     HttpServletResponse resp,
     String JavaScriptExpression)
     throws IOException {
     PrintWriter out = resp.getWriter( );
     HttpSession session = req.getSession( );
     // Generates a unique key, that will be used to store/retrieve the
     // missing value in the current HTTP session
     String key = generateKey( );
     // Starts the generation of a JavaScript that will retrieve
     // the information from the client’s web-browser
     out.println(“ <script language=\“JavaScript\”>”);
     // In this example the client’s web-browser will prompt the user to enter
     the missing value
     out.println(“var value = “ + JavaScriptExpression + ”;”);
     // once the value has been retrieved on stored on the client side
     // in a JavaScript variable, transmit this value to the server through
     // the secondary Servlet
     // Makes the client’s web-browser open an HTTP request to the secondary Servlet,
     // passing the key and value of the missing information
     out.println(“var httpReq = new XMLHttpRequest( );”);
     out.println(
      “httpReq.open(\“GET\”,\“”
       + SECONDARY_SERVLET_URL
       + “?key=”
       + key
       + “&value=\”+value,true);”);
     out.println(“httpReq.send(null);”);
     out.println(“ </script>”);
     // Flushes the buffer of the Servlet, so that the JavaScript retrieving the
     // missing value is transmitted and executed immediately by the client’s
     web-browser
     resp.flushBuffer( );
     // Suspends the execution of the main Servlet until a value can be found
     // in the HTTP session under the key defined previously
     Object value = session.getAttribute(key);
     while (value == null) {
      try {
       Thread.sleep(100);
      } catch (InterruptedException e) {
       e.printStackTrace( );
      }
      value = session.getAttribute(key);
     }
     // Now that the value has been extracted, remove its key/value pair from
     // the session, to avoid memory leaks and allow the same key to be reused
     // several times
     session.removeAttribute(key);
     return value;
       }
      }
  • Source 2: Secondary servlet
     Import java.io.*;
     import javax.servlet.*;
     import javax.servlet.http.*;
     /**
      * Secondary Servlet updating the HTTP session with key/value pairs.
      * The key/value pairs to store are contained in the incoming requests
      * under the keys “key” and “value”.
      * For example a request containing the parameters
      * “mySecondaryServletURL?key=myKey&value=myvalue”
      * will store the value “myValue” under the key “myKey” in the
      HTTP session.
      */
     public class SecondaryServlet extends HttpServlet implements Servlet {
     /**
     * @see javax.servlet.http.Httpservlet#void
    (javax.servlet.http.HttpServletRequest,
    javax.servlet.http.HttpServletResponse)
      */
      public void doGet(HttpservletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
      // Extracts from the request coming from the browser the key/value
      // pair to store in the HTTP session
      String key = req.getParameter(“key”);
      String value = req.getParameter(“value”);
      if (key != null) {
       // Store this key/value pair in the HTTP session
       req.getSession( ):setAttribute(key, value);
       }
     }
     }

Claims (11)

1. A method comprising:
providing a one way communication path that initiates a request by a client for retrieving information from a Servlet, and sending a response by the Servlet containing at least return code specifying success or failure of the request, and including the result of the request if available; and
if the Servlet identifies missing information not included in the initial request, providing a complete response to automatically open an other communication path from the Servlet via the client's web-browser to the Servlet and providing the missing information to a Servlet by making use of a response functionality of the initial request, wherein the other communication path is supported by a further Servlet functionality component.
2. The method of claim 1, wherein the further Servlet functionality component comprises:
generating a script when executed at the client's web-browser retrieves the missing information and invokes the further Servlet functionality component by the Servlet;
appending the script to the response indicating it as a partial response;
sending the response including the script to the client's web-browser.
suspending execution of the initial response by the Servlet until the missing information will be available;
receiving the missing information by the further Servlet functionality component, wherein the missing information is contained in a new request created by the script during its execution on the client's web-browser;
providing the missing information to Servlet, and
continuing execution of the initial response by the Servlet using the missing information for retrieving the rest of the response and providing the rest of the response to the client's web-browser for displaying.
3. The method according to claim 1, wherein the communication protocol is the HTTP protocol.
4. The method according to claim 1, wherein the further Servlet functionality component is implemented as separate secondary Servlet.
5. The method according to claim 3, wherein the secondary Servlet receives new HTTP-request sent by the script, and stores the missing information in a shared memory used by both Servlets.
6. The method according to claim 3, wherein the missing information is stored by the secondary Servlet in the current HTTP session object between the client and the server and passed to the Servlet.
7. The method according to claim 1, wherein the further Servlet functionality component is part of the Servlet and receipt of the new HTTP request by the Servlet automatically starts a second instance of the Servlet, and updates the current HTTP session object with the missing information.
8. The method according to claim 1, wherein execution of the script by the web-browser automatically retrieves the missing information or retrieves the missing information by an additional user input.
9. The method according to claim 1, wherein the Servlet is implemented as a Java Servlet.
10. The method according to claim 1, wherein the script is implemented as a Java Script.
11. The method according to claim 1, wherein the script contains the missing information with an assigned key generated by the Servlet.
US11/817,674 2005-09-08 2007-08-31 Method and system for improving client-servlet communication Abandoned US20090164613A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
EP05108239 2005-09-08
EP05108239.4 2005-09-08
PCT/EP2006/064658 WO2007028670A1 (en) 2005-09-08 2006-07-26 Method and system for improving client-servlet communication
EPPCT/EP2006/064658 2006-07-26

Publications (1)

Publication Number Publication Date
US20090164613A1 true US20090164613A1 (en) 2009-06-25

Family

ID=35610123

Family Applications (2)

Application Number Title Priority Date Filing Date
US11/817,672 Active 2029-01-31 US8566390B2 (en) 2005-09-08 2006-07-26 Method and system for improving client-Servlet communication
US11/817,674 Abandoned US20090164613A1 (en) 2005-09-08 2007-08-31 Method and system for improving client-servlet communication

Family Applications Before (1)

Application Number Title Priority Date Filing Date
US11/817,672 Active 2029-01-31 US8566390B2 (en) 2005-09-08 2006-07-26 Method and system for improving client-Servlet communication

Country Status (8)

Country Link
US (2) US8566390B2 (en)
EP (1) EP1922655B1 (en)
JP (1) JP4640682B2 (en)
KR (1) KR100962893B1 (en)
CN (1) CN101258494B (en)
AT (1) ATE426856T1 (en)
DE (1) DE602006005943D1 (en)
WO (1) WO2007028670A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100031183A1 (en) * 2008-08-01 2010-02-04 Samsung Electronics Co., Ltd. Electronic device and web information providing method thereof
US20100082823A1 (en) * 2008-09-28 2010-04-01 International Business Machines Corporation Method and system for separating http session
US20120016981A1 (en) * 2010-07-15 2012-01-19 Alexander Clemm Continuous autonomous monitoring of systems along a path
US8555083B1 (en) * 2010-07-22 2013-10-08 Symantec Corporation Systems and methods for protecting against unauthorized access of encrypted data during power-management modes
US8995266B2 (en) 2010-07-07 2015-03-31 Cisco Technology, Inc. Performing path-oriented systems management
US20230099368A1 (en) * 2021-09-30 2023-03-30 Intuit Inc. Conversational user interfaces based on knowledge graphs

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080228715A1 (en) * 2007-03-12 2008-09-18 Terabyte Media, Llc Apparatus and method for distributed information retrieval and processing
US8079025B2 (en) * 2007-06-08 2011-12-13 Apple Inc. Asynchronous load of source dependencies
US8127038B2 (en) 2008-03-11 2012-02-28 International Business Machines Corporation Embedded distributed computing solutions
US8949408B2 (en) * 2009-12-18 2015-02-03 Microsoft Corporation Session monitoring of virtual desktops in a virtual machine farm
US8880594B2 (en) * 2010-11-29 2014-11-04 Hughes Network Systems, Llc Computer networking system and method with Javascript execution for pre-fetching content from dynamically-generated URL
US20120197971A1 (en) * 2011-02-01 2012-08-02 Shiarng Llc Enhanced web-browsing system and method
US9021109B1 (en) * 2012-01-23 2015-04-28 Amazon Technologies, Inc. Controlling requests through message headers
US9525754B1 (en) * 2012-09-28 2016-12-20 EMC IP Holding Company LLC Task-based approach to execution, monitoring and execution control of actions
US9537350B2 (en) 2013-03-15 2017-01-03 Regal Beloit America, Inc. Switch-mode power supply with a dual primary transformer
US9292373B2 (en) * 2013-03-15 2016-03-22 International Business Machines Corporation Query rewrites for data-intensive applications in presence of run-time errors
US10103961B2 (en) * 2014-07-25 2018-10-16 Teacher Insurance & Annuity Association of America Collecting client-side application performance monitoring information
US10778744B2 (en) * 2015-08-13 2020-09-15 Molbase (Shanghai) Biotechnology Co., Ltd. Configurable caching system and method thereof
US10462145B2 (en) * 2016-07-15 2019-10-29 The Directv Group, Inc. Method and apparatus for controlling access to custom browser functionality
CN109951567A (en) * 2019-04-02 2019-06-28 山东浪潮云信息技术有限公司 A kind of Double Data center applications dispositions method
CN114629885A (en) * 2021-01-05 2022-06-14 亚信科技(中国)有限公司 Service request processing method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6012098A (en) * 1998-02-23 2000-01-04 International Business Machines Corp. Servlet pairing for isolation of the retrieval and rendering of data
US20040168122A1 (en) * 2003-02-21 2004-08-26 Kobipalayam Murugaiyan Senthil Nathan System, method and computer readable medium for transferring and rendering a web page
US7426535B2 (en) * 2002-10-08 2008-09-16 Telecommunication Systems, Inc. Coordination of data received from one or more sources over one or more channels into a single context

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB9924259D0 (en) 1999-10-13 1999-12-15 Duncan Graham L Interactive service system
JP2002116983A (en) * 2000-10-02 2002-04-19 Hewlett Packard Co <Hp> Method and system for converting web contents
US20020133567A1 (en) 2001-01-12 2002-09-19 Te George A. Method and system for generalized common gateway interface processing
US20030145048A1 (en) 2002-01-18 2003-07-31 Bea Systems, Inc. System and method for HTTP request preprocessing for servlets and application servers
EP1536349A4 (en) * 2002-09-03 2005-11-16 Fujitsu Ltd Search system, search server, client, search method, program, and recording medium
CN1619559A (en) * 2003-11-18 2005-05-25 华为技术有限公司 Method of providing service to customer and its system
JP4532885B2 (en) * 2003-12-01 2010-08-25 キヤノン株式会社 Server computer and method of providing page data to communication terminal via network by server computer

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6012098A (en) * 1998-02-23 2000-01-04 International Business Machines Corp. Servlet pairing for isolation of the retrieval and rendering of data
US7426535B2 (en) * 2002-10-08 2008-09-16 Telecommunication Systems, Inc. Coordination of data received from one or more sources over one or more channels into a single context
US20040168122A1 (en) * 2003-02-21 2004-08-26 Kobipalayam Murugaiyan Senthil Nathan System, method and computer readable medium for transferring and rendering a web page

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100031183A1 (en) * 2008-08-01 2010-02-04 Samsung Electronics Co., Ltd. Electronic device and web information providing method thereof
US9633132B2 (en) * 2008-08-01 2017-04-25 Samsung Electronics Co., Ltd. Electronic device and web information providing method thereof
US20100082823A1 (en) * 2008-09-28 2010-04-01 International Business Machines Corporation Method and system for separating http session
US8484360B2 (en) * 2008-09-28 2013-07-09 International Business Machines Corporation Method and system for separating HTTP session
US8995266B2 (en) 2010-07-07 2015-03-31 Cisco Technology, Inc. Performing path-oriented systems management
US9787593B2 (en) 2010-07-07 2017-10-10 Cicsco Technology, Inc. Performing path-oriented systems management
US20120016981A1 (en) * 2010-07-15 2012-01-19 Alexander Clemm Continuous autonomous monitoring of systems along a path
US8838781B2 (en) * 2010-07-15 2014-09-16 Cisco Technology, Inc. Continuous autonomous monitoring of systems along a path
US9565082B2 (en) 2010-07-15 2017-02-07 Cisco Technology, Inc. Continuous autonomous monitoring of systems along a path
US10110451B2 (en) 2010-07-15 2018-10-23 Cisco Technology, Inc. Continuous autonomous monitoring of systems along a path
US8555083B1 (en) * 2010-07-22 2013-10-08 Symantec Corporation Systems and methods for protecting against unauthorized access of encrypted data during power-management modes
US20230099368A1 (en) * 2021-09-30 2023-03-30 Intuit Inc. Conversational user interfaces based on knowledge graphs

Also Published As

Publication number Publication date
JP2009508197A (en) 2009-02-26
CN101258494B (en) 2010-10-27
EP1922655A1 (en) 2008-05-21
US20090125579A1 (en) 2009-05-14
ATE426856T1 (en) 2009-04-15
JP4640682B2 (en) 2011-03-02
KR100962893B1 (en) 2010-06-09
KR20080041634A (en) 2008-05-13
CN101258494A (en) 2008-09-03
EP1922655B1 (en) 2009-03-25
WO2007028670A1 (en) 2007-03-15
DE602006005943D1 (en) 2009-05-07
US8566390B2 (en) 2013-10-22

Similar Documents

Publication Publication Date Title
US8566390B2 (en) Method and system for improving client-Servlet communication
US8266202B1 (en) System and method for auto-generating JavaScript proxies and meta-proxies
US20150095763A1 (en) Browser emulator system
US8954989B1 (en) Flexible, event-driven JavaScript server architecture
US7890604B2 (en) Client-side callbacks to server events
US8161472B2 (en) Methods and apparatus for incorporating a partial page on a client
US8639743B1 (en) System and method for on-the-fly rewriting of JavaScript
US8819539B1 (en) On-the-fly rewriting of uniform resource locators in a web-page
US20090144753A1 (en) Method And System For Providing Update Content In A Markup Language-Based Resource
US20120297288A1 (en) Method and System for Enhancing Web Content
US8756579B1 (en) Client-side and server-side unified validation
US20110264729A1 (en) Augmentation of network traffic
US20060235942A1 (en) System for processing requests to portlets
US20140245124A1 (en) System and method thereof for browser agnostic extension models
EP2760183A1 (en) System for detecting hyperlink faults
US20020087915A1 (en) Error handler method and system for internet-based applications
CA2297597A1 (en) Method and system for testing internet-based applications
Maughan Test case generation using combinatorial based coverage for rich web applications
US20240004785A1 (en) Configuration-based system and method for handling transient data in complex systems
US10834167B1 (en) Client side navigation compositor
US8533291B1 (en) Method and system for protecting publicly viewable web client reference to server resources and business logic
Tu et al. Performance Tuning and Optimizing ASP. NET Applications
Chen-Becker et al. Advanced Lift Architecture
Scholtz et al. Exception Handling
Sambells et al. AdvancED DOM Scripting: Dynamic Web Design Techniques

Legal Events

Date Code Title Description
STCB Information on status: application discontinuation

Free format text: ABANDONED -- FAILURE TO RESPOND TO AN OFFICE ACTION