Files Prepare Run Troubleshooting Related Topics
This example demonstrates how to use the AbstractAsyncServlet with AJAX by implementing a simple chat application.
The example includes two Servlets: ChatSendServlet that receives the chat message request, and ChatReceiveServlet that handles polling message request by the AJAX client.
ChatReceiveServlet decouples the receipt of a servlet request from the sending of its response. If there are no queued messages, ChatReceiveServlet sends the Responses in the future upon the arrival of new messages or timeout. The ChatReceiveServlet does not consume any threads while waiting for the new messages within the timeout period.
Directory Location:
BEA_HOME/wlserver_10.3/samples/server/examples/webapp/servlets/async/
(where BEA_HOME is the directory containing your WebLogic Server installation)
File Click source files to view code. |
Description |
|---|---|
| application.xml | The Java EE standard enterprise application deployment descriptor. |
| build.xml | Ant build file that contains targets for building and running the example. |
| ExamplesFooter.jsp | Java Server Page containing the Example Footer. |
| ExamplesHeader.jsp | Java Server Page containing the Example Header. |
| main.jsp | The main Java Server Page of the chatting program. |
| chat.js | JavaScript file that sends chat messages to and polls messages from the Chat Server. |
| ChatSendServlet.java | Servlet that processes the message sent by the AJAX Client . |
| ChatReceiveServlet.java | An implementation of AbstractAsyncServlet. |
| ChatSession.java | A simple class responsible for maintaining the users and messages . |
| web.xml | The standard Web application deployment descriptor. |
Before working with this example:
No special configuration is required for this example
To build the example, follow these steps:
SAMPLES_HOME\server\examples\src\examples\webapp\servlets\async directory,
where SAMPLES_HOME refers
to the main WebLogic Server examples
directory, such as d:\bea\wlserver_10.3\samples. ant buildant deploy wl_server domain
of your WebLogic Server installation. To run the example, follow these steps:
SAMPLES_HOME\server\examples\src\examples\webapp\servlets\async):
prompt> ant run
http://localhost:port/asyncServlet/main.jsp
where
localhost refers to the machine on which WebLogic Server is running
port refers to port on which WebLogic Server is listening
(Internet connection required.)
Copyright © 1996, 2008, Oracle and/or its affiliates. All Rights Reserved.