← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5565: minor fix in redirect

 

------------------------------------------------------------
revno: 5565
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-23 14:40:30 +0100
message:
  minor fix in redirect
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java	2011-12-23 12:04:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/MappedRedirectStrategy.java	2011-12-23 13:40:30 +0000
@@ -95,11 +95,28 @@
             //
             //  url = request.getHeader( "referer" ).replaceFirst( "/dhis-web-commons/security/login.action",
             //  "/mobile/index.action" );
-            url = request.getContextPath() + "/mobile/index.action";
+            url = getRootPath( request ) + "/mobile/index.action";
         }
 
         log.debug( "Redirecting to " + url );
 
         super.sendRedirect( request, response, url );
     }
+
+    public String getRootPath( HttpServletRequest request )
+    {
+        StringBuilder builder = new StringBuilder();
+        builder.append( request.getScheme() );
+
+        builder.append( "://" ).append( request.getServerName() );
+
+        if ( request.getServerPort() != 80 && request.getServerPort() != 443 )
+        {
+            builder.append( ":" ).append( request.getServerPort() );
+        }
+
+        builder.append( request.getContextPath() );
+
+        return builder.toString();
+    }
 }