Author: jfrederic.clere(a)jboss.com
Date: 2011-01-27 10:24:30 -0500 (Thu, 27 Jan 2011)
New Revision: 1640
Modified:
sandbox/webapps/src/TestAsyncServlet.java
Log:
Example no working with native at TC7.
Modified: sandbox/webapps/src/TestAsyncServlet.java
===================================================================
--- sandbox/webapps/src/TestAsyncServlet.java 2011-01-17 11:21:35 UTC (rev 1639)
+++ sandbox/webapps/src/TestAsyncServlet.java 2011-01-27 15:24:30 UTC (rev 1640)
@@ -45,7 +45,7 @@
// @WebServlet("/TestAsyncServlet")
@WebServlet(urlPatterns = {"/TestAsyncServlet"}, asyncSupported = true)
public class TestAsyncServlet extends HttpServlet {
- public void doPost(HttpServletRequest req, HttpServletResponse res) {
+ public void doGet(HttpServletRequest req, HttpServletResponse res) {
// Servlet Code
// ...........
// Call startAsync
@@ -53,26 +53,31 @@
// Give AsyncContext to the Listener MonListener
context.addListener(new MonListener());
// ...........
+ context.complete();
}
public class MonListener implements AsyncListener {
- public void onComplete(AsyncEvent event) {
+ public void onComplete(AsyncEvent event) throws IOException {
System.out.println("onComplete");
+
event.getAsyncContext().getResponse().getWriter().println("onComplete");
}
- public void onError(AsyncEvent event) {
+ public void onError(AsyncEvent event) throws IOException {
ServletResponse res = event.getSuppliedResponse();
System.out.println("onError: " + res);
+ event.getAsyncContext().getResponse().getWriter().println("onError");
}
- public void onTimeout(AsyncEvent event) {
+ public void onTimeout(AsyncEvent event) throws IOException {
ServletResponse res = event.getSuppliedResponse();
try {
ServletOutputStream os = res.getOutputStream();
System.out.println("onTimeout: " + res);
} catch (Exception e) {
}
+
event.getAsyncContext().getResponse().getWriter().println("onTimeout");
}
- public void onStartAsync(AsyncEvent event) {
+ public void onStartAsync(AsyncEvent event) throws IOException {
System.out.println("onStartAsync");
+
event.getAsyncContext().getResponse().getWriter().println("onStartAsync");
}
}
Show replies by date