diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
index 0f8219b785..e73023c0b3 100644
--- a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
+++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
@@ -20,7 +20,9 @@ package org.apache.activemq.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -62,7 +64,7 @@ public class MessageListenerServlet extends MessageServletSupport {
private long defaultReadTimeout = -1;
- private long maximumReadTimeout = 10000;
+ private long maximumReadTimeout = 25000;
private int maximumMessages = 100;
@@ -99,7 +101,7 @@ public class MessageListenerServlet extends MessageServletSupport {
synchronized (client) {
// System.err.println("POST client="+client+" session="+request.getSession().getId()+" info="+request.getPathInfo()+" contentType="+request.getContentType());
-
+ // dump(request.getParameterMap());
String[] destinations = request.getParameterValues("destination");
String[] messages = request.getParameterValues("message");
String[] types = request.getParameterValues("type");
@@ -169,6 +171,10 @@ public class MessageListenerServlet extends MessageServletSupport {
throw new ServletException("JMS problem: " + e, e);
}
}
+ else
+ {
+ response.getWriter().print("");
+ }
// System.err.println("==");
}
@@ -178,26 +184,16 @@ public class MessageListenerServlet extends MessageServletSupport {
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String end="--";
try {
WebClient client = getWebClient(request);
// System.err.println("GET client="+client+" session="+request.getSession().getId()+" uri="+request.getRequestURI()+" query="+request.getQueryString());
doMessages(client, request, response);
}
- catch(RetryRequest r)
- {
- end="??";
- throw r;
- }
catch (JMSException e) {
throw new ServletException("JMS problem: " + e, e);
}
- finally
- {
- // System.err.println(end);
- }
-
+ // System.err.println("--");
}
/**
@@ -307,55 +303,6 @@ public class MessageListenerServlet extends MessageServletSupport {
}
- /**
- * Subscribe or unsubscribe to a destination. The listen request parameter
- * is used to indicate subscribe (tree) or unsubscribe (false).
- *
- * @param request
- * @param response
- * @throws ServletException
- * @throws IOException
- */
- protected void doSubscription(WebClient client, Destination destination, HttpServletRequest request, HttpServletResponse response) throws JMSException, ServletException, IOException {
-
- // System.err.println("doSubscription destination="+destination);
- String s = request.getParameter("listen");
- if (s == null || s.length() == 0) {
- log.warn("No listen paramenter for subscribe");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No listen parameter");
- return;
- }
- boolean listen = Boolean.valueOf(s).booleanValue();
-
- String id = request.getParameter("id");
- if (listen && (id == null || id.length() == 0)) {
- log.warn("No id paramenter for subscribe");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No id parameter");
- return;
- }
-
- Listener listener = getListener(request);
- Map consumerIdMap = getConsumerIdMap(request);
-
- synchronized (client) {
- MessageAvailableConsumer consumer = (MessageAvailableConsumer) client.getConsumer(destination);
-
- if (listen) {
- consumer.setAvailableListener(listener);
- consumerIdMap.put(consumer, id);
- // System.err.println("Subscribed: "+consumer+" to
- // "+destination);
- } else {
- // TODO should we destroy consumer on unsubscribe?
- consumer.setAvailableListener(null);
- consumerIdMap.remove(consumer);
- // System.err.println("Unsubscribed: "+consumer);
- }
- }
-
- response.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
-
protected void writeMessageResponse(PrintWriter writer, Message message) throws JMSException, IOException {
if (message instanceof TextMessage) {
TextMessage textMsg = (TextMessage) message;
@@ -441,4 +388,15 @@ public class MessageListenerServlet extends MessageServletSupport {
}
+ private static void dump(Map map)
+ {
+ Iterator iter=map.entrySet().iterator();
+ while(iter.hasNext())
+ {
+ Map.Entry entry=(Map.Entry)iter.next();
+ String k=(String)entry.getKey();
+ String[] v=(String[])entry.getValue();
+ System.err.println(k+":"+(v==null?"[]":Arrays.asList(v).toString()));
+ }
+ }
}
diff --git a/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java b/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java
new file mode 100644
index 0000000000..040bb6a219
--- /dev/null
+++ b/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.web;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+
+/* ------------------------------------------------------------ */
+/** SessionFilter.
+ * Simple filter to ensure that all clients have a session.
+ * Prevents problems with AJAX requests.
+ */
+public class SessionFilter implements Filter{
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ HttpSession session=((HttpServletRequest)request).getSession(true);
+ // if (session.isNew())
+ // System.err.println("NEW SESSION "+session.getId()+" for "+((HttpServletRequest)request).getRequestURI());
+ chain.doFilter(request,response);
+ }
+
+ public void destroy() {
+ }
+
+}
diff --git a/activemq-web/src/main/webapp/WEB-INF/web.xml b/activemq-web/src/main/webapp/WEB-INF/web.xml
index 9cfd8b8e59..fca36b5fb6 100755
--- a/activemq-web/src/main/webapp/WEB-INF/web.xml
+++ b/activemq-web/src/main/webapp/WEB-INF/web.xml
@@ -70,4 +70,13 @@
/portfolioPublish
+
+ session
+ org.apache.activemq.web.SessionFilter
+
+
+
+ session
+ /*
+
diff --git a/activemq-web/src/main/webapp/chat.js b/activemq-web/src/main/webapp/chat.js
index e84527c235..5f20479169 100755
--- a/activemq-web/src/main/webapp/chat.js
+++ b/activemq-web/src/main/webapp/chat.js
@@ -58,9 +58,9 @@ var room =
$('join').className='';
$('joined').className='hidden';
$('username').focus();
- room._username=null;
Behaviour.apply();
amq.sendMessage(chatMembership, "");
+ room._username=null;
},
chat: function()
diff --git a/activemq-web/src/main/webapp/index.html b/activemq-web/src/main/webapp/index.html
index bc9fd3176c..f29106067c 100755
--- a/activemq-web/src/main/webapp/index.html
+++ b/activemq-web/src/main/webapp/index.html
@@ -14,8 +14,6 @@ normal HTTP POST and to receive messages from a destination using a
HTTP GET.
-Currently only working with firefox!
-
Market data example
diff --git a/activemq-web/src/main/webapp/js/amq.js b/activemq-web/src/main/webapp/js/amq.js
index 40a243892e..639fc1a66e 100644
--- a/activemq-web/src/main/webapp/js/amq.js
+++ b/activemq-web/src/main/webapp/js/amq.js
@@ -119,10 +119,13 @@ var amq =
{
new Ajax.Request('/amq', { method: 'post', postBody: 'destination='+destination+'&message='+message+'&type='+type});
}
+ },
+
+ _startPolling : function()
+ {
+ new Ajax.Request('/amq', { method: 'get', parameters: 'timeout=0', onSuccess: amq._pollHandler });
}
-
-
};
-Behaviour.addLoadEvent(function(){new Ajax.Request('/amq', { method: 'get', parameters: 'timeout=0', onSuccess: amq._pollHandler });});
+Behaviour.addLoadEvent(amq._startPolling);
diff --git a/activemq-web/src/main/webapp/js/behaviour.js b/activemq-web/src/main/webapp/js/behaviour.js
index 74b5735cf3..fdde861bba 100644
--- a/activemq-web/src/main/webapp/js/behaviour.js
+++ b/activemq-web/src/main/webapp/js/behaviour.js
@@ -1,5 +1,5 @@
/*
- Behaviour v1.0 by Ben Nolan, June 2005. Based largely on the work
+ Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
of Simon Willison (see comments by Simon below).
Description:
@@ -29,7 +29,7 @@
License:
- My stuff is BSD licensed. Not sure about Simon's.
+ This file is entirely BSD licensed.
More information:
diff --git a/activemq-web/src/main/webapp/portfolio/portfolio.js b/activemq-web/src/main/webapp/portfolio/portfolio.js
index cf4239f818..296b0ec021 100644
--- a/activemq-web/src/main/webapp/portfolio/portfolio.js
+++ b/activemq-web/src/main/webapp/portfolio/portfolio.js
@@ -40,12 +40,8 @@ function portfolioPoll(first)
}
}
-function portfolioInit()
-{
- amq.addPollHandler(portfolioPoll);
-}
+amq.addPollHandler(portfolioPoll);
-Behaviour.addLoadEvent(portfolioInit);
/// -----------------
// Original code by Joe Walnes