Lifecycle of an AJAX file upload request made in a application
The following list describes how an AJAX request is processed in a application.
1 A file upload request is made by a user and is then sent from the browser to the server side. The file upload request contains the following information: the current processor ID, session ID and file upload data ID.
2 The FileuploadServlet class receives the request and assigns a thread to process the request. The FileuploadServlet class also assembles the resources that are required to process the file upload request, and then it delegates the service() method to the thread.
3 The thread processes the service() method, handles the file upload request, creates a new channel driver, channel request/response messages and a channel context.
4 The Channel driver initializes the channel context, parses file upload request data, and updates the channel context data.
5 The AjaxHtmlRequestHandler checks whether the request is a duplicated request, updates the channel context, and loads the file upload operation. The file upload operation retrieves the file upload data by using the ID of the file upload data, find the real file handler implClass, then load the file handler and then leverage file handler to finish the real file upload work
▪ File handler initializes parameters based on file upload request data.
▪ Validates the file upload request, e.g check file size limitation or extension, it depends on the real implementation.
▪ Saves the file stream to proper storage. E.g file system or database.
▪ Updates data in the processor context so that the file can be accessed later.
6 The AjaxHtmlPresentationHandler sends the response message to the FileuploadServlet class, then routes the response to the client browser.