You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2010/01/25 14:30:51 UTC

svn commit: r902806 - in /labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website: Dispatch.java utils/LinkHelper.java

Author: simoneg
Date: Mon Jan 25 13:30:51 2010
New Revision: 902806

URL: http://svn.apache.org/viewvc?rev=902806&view=rev
Log:
Workaround web containers inconsistencies about "+" in urls

Modified:
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/utils/LinkHelper.java

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java?rev=902806&r1=902805&r2=902806&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java (original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/Dispatch.java Mon Jan 25 13:30:51 2010
@@ -76,18 +76,10 @@
 	protected void handle(HttpServletRequest req, HttpServletResponse resp) {
 		String pathInfo = req.getPathInfo();
 		String enc = req.getCharacterEncoding();
-		if (enc == null) enc = "UTF-8";
-		try {
-			pathInfo = URLDecoder.decode(pathInfo, enc);
-		} catch (UnsupportedEncodingException uee) {
-			try {
-				pathInfo = URLDecoder.decode(pathInfo, "UTF-8");
-			} catch (UnsupportedEncodingException uee2) {}
-		}
 		while (pathInfo.indexOf("//") != -1) {
 			pathInfo = pathInfo.replaceAll("//", "/");
 		}
-		req.setAttribute("__magma_url", pathInfo);
+		req.setAttribute("magma_url", pathInfo);
 		RootWebHandler.getInstance().beforeRequest();
 		
 		// Find the extension to determine the postprocessing
@@ -247,7 +239,7 @@
 		Template t = producer.getTemplate();
 		if (t == null) {
 			// If there is not, try using the previous template
-			Class<Template> tplcl = (Class<Template>) session.getAttribute("__magma_lasttemplate");
+			Class<Template> tplcl = (Class<Template>) session.getAttribute("magma_lasttemplate");
 			if (tplcl != null) {
 				try {
 					t = tplcl.newInstance();
@@ -268,7 +260,7 @@
 		t.setCurrent(producer);
 		
 		// Prepare a previous giver, in case the template needs the previous main page
-		final String last = (String) session.getAttribute("__magma_lastmain");
+		final String last = (String) session.getAttribute("magma_lastmain");
 		PreviousGiver giver = new PreviousGiver() {
 			public HtmlProducer getPrevious() {
 				try {
@@ -308,8 +300,8 @@
 		
 		if (t.wasMain() && producer.isRepeatable()) {
 			System.out.println("Producer has a reproducible main path of " + producer.getCompletePath());
-			session.setAttribute("__magma_lastmain", producer.getCompletePath());			
-			session.setAttribute("__magma_lasttemplate", t.getClass());
+			session.setAttribute("magma_lastmain", producer.getCompletePath());			
+			session.setAttribute("magma_lasttemplate", t.getClass());
 		} else {	
 			System.out.println("Producer has a not reproducible OR not main path of " + producer.getCompletePath());
 		}

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/utils/LinkHelper.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/utils/LinkHelper.java?rev=902806&r1=902805&r2=902806&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/utils/LinkHelper.java (original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/utils/LinkHelper.java Mon Jan 25 13:30:51 2010
@@ -98,6 +98,10 @@
 					String converted = converters[i].to(param);
 					try {
 						converted = URLEncoder.encode(converted, "UTF-8");
+						// Jetty and Tomcat behaves differently in regard to "+" in path info.
+						// Jetty does not parse it while Tomcat converts it to space.
+						// Better not to have "+" at all.
+						converted = converted.replaceAll("\\+", "%20");
 					} catch (UnsupportedEncodingException e) {
 						// should never happen for UTF-8
 					}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org