aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-10-10 12:56:09 +0300
committerVaadin Code Review <review@vaadin.com>2014-04-09 06:31:10 +0000
commit3edf6bd933804413094aca2cd678a0f58369d7d0 (patch)
tree6ea3322580242ab52cb20537e80e23a88df9dc1a /server/src
parenteb5ffa3a414c2def6d669067f647c06c70c3c5eb (diff)
downloadvaadin-framework-3edf6bd933804413094aca2cd678a0f58369d7d0.tar.gz
vaadin-framework-3edf6bd933804413094aca2cd678a0f58369d7d0.zip
Don't add slash after jsessionid in URL (#12307)
Change-Id: Ic329b4307bcc0613e6c0160375003d4b9f7e7ee1
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java46
1 files changed, 44 insertions, 2 deletions
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 3da264e0e7..2d4d11785a 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -258,14 +258,22 @@ public class VaadinServlet extends HttpServlet implements Constants {
*/
protected boolean handleContextRootWithoutSlash(HttpServletRequest request,
HttpServletResponse response) throws IOException {
+ // Query parameters like "?a=b" are handled by the servlet container but
+ // path parameter (e.g. ;jsessionid=) needs to be handled here
+ String location = request.getRequestURI();
+
+ String lastPathParameter = getLastPathParameter(location);
+ location = location.substring(0,
+ location.length() - lastPathParameter.length());
+
if ((request.getPathInfo() == null || "/".equals(request.getPathInfo()))
&& "".equals(request.getServletPath())
- && !request.getRequestURI().endsWith("/")) {
+ && !location.endsWith("/")) {
/*
* Path info is for the root but request URI doesn't end with a
* slash -> redirect to the same URI but with an ending slash.
*/
- String location = request.getRequestURI() + "/";
+ location = location + "/" + lastPathParameter;
String queryString = request.getQueryString();
if (queryString != null) {
location += '?' + queryString;
@@ -277,6 +285,40 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
}
+ /**
+ * Finds any path parameter added to the last part of the uri. A path
+ * parameter is any string separated by ";" from the path and ends in / or
+ * at the end of the string.
+ * <p>
+ * For example the uri http://myhost.com/foo;a=1/bar;b=1 contains two path
+ * parameters, {@literal a=1} related to {@literal /foo} and {@literal b=1}
+ * related to /bar.
+ * <p>
+ * For http://myhost.com/foo;a=1/bar;b=1 this method will return ;b=1
+ *
+ * @since 7.2
+ * @param uri
+ * a URI
+ * @return the last path parameter of the uri including the semicolon or an
+ * empty string. Never null.
+ */
+ protected static String getLastPathParameter(String uri) {
+ int lastPathStart = uri.lastIndexOf('/');
+ if (lastPathStart == -1) {
+ return "";
+ }
+
+ int semicolonPos = uri.indexOf(';', lastPathStart);
+ if (semicolonPos < 0) {
+ // No path parameter for the last part
+ return "";
+ } else {
+ // This includes the semicolon.
+ String semicolonString = uri.substring(semicolonPos);
+ return semicolonString;
+ }
+ }
+
private VaadinServletResponse createVaadinResponse(
HttpServletResponse response) {
return new VaadinServletResponse(response, getService());