1 20 package org.apache.cactus.internal.server; 21 22 import java.net.URLDecoder ; 23 24 import org.apache.cactus.util.ChainedRuntimeException; 25 26 31 public class ServletUtil 32 { 33 51 public static String getQueryStringParameter(String theQueryString, 52 String theParameter) 53 { 54 if (theQueryString == null) 55 { 56 return null; 57 } 58 59 String value = null; 60 61 int startIndex = theQueryString.indexOf(theParameter + "="); 62 63 if (startIndex >= 0) 64 { 65 startIndex += (theParameter.length() + 1); 67 68 int endIndex = theQueryString.indexOf('&', startIndex); 69 70 if (endIndex > startIndex) 71 { 72 value = theQueryString.substring(startIndex, endIndex); 73 } 74 else if (endIndex == startIndex) 75 { 76 value = ""; 77 } 78 else 79 { 80 value = theQueryString.substring(startIndex); 81 } 82 83 try 86 { 87 value = URLDecoder.decode(value); 88 } 89 catch (Exception e) 90 { 91 throw new ChainedRuntimeException("Error URL decoding [" 92 + value + "]", e); 93 } 94 } 95 96 return value; 97 } 98 } 99 | Popular Tags |