Revision 5751
Added by berkley almost 14 years ago
src/edu/ucsb/nceas/metacat/restservice/D1HttpRequest.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.util.Enumeration; |
27 | 27 |
import java.util.Map; |
28 |
import java.util.StringTokenizer; |
|
28 | 29 |
|
29 | 30 |
import javax.servlet.ServletRequest; |
30 | 31 |
import javax.servlet.http.*; |
... | ... | |
53 | 54 |
}*/ |
54 | 55 |
System.out.println("request uri: " + this.request.getRequestURI()); |
55 | 56 |
String reqUri = this.request.getRequestURI(); |
56 |
this.lastPathElement = reqUri.substring(reqUri.lastIndexOf("/"), reqUri.length()); |
|
57 |
StringTokenizer st = new StringTokenizer(reqUri, "/"); |
|
58 |
if(st.countTokens() <= 3) |
|
59 |
{ |
|
60 |
lastPathElement = "/"; |
|
61 |
} |
|
62 |
else if(st.countTokens() > 3) |
|
63 |
{ |
|
64 |
st.nextToken(); |
|
65 |
st.nextToken(); |
|
66 |
st.nextToken(); |
|
67 |
lastPathElement = "/"; |
|
68 |
while(st.hasMoreTokens()) |
|
69 |
{ |
|
70 |
lastPathElement += st.nextToken(); |
|
71 |
lastPathElement += "/"; |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
if(lastPathElement.endsWith("/")) |
|
77 |
{ |
|
78 |
lastPathElement = lastPathElement.substring(0, lastPathElement.length() - 1); |
|
79 |
} |
|
57 | 80 |
} |
58 | 81 |
|
59 | 82 |
/** |
... | ... | |
63 | 86 |
@Override |
64 | 87 |
public String getPathInfo() |
65 | 88 |
{ |
66 |
//String s = super.getPathInfo(); |
|
67 |
String s = this.lastPathElement; |
|
68 |
System.out.println("pathinfo: " + s); |
|
89 |
String s = super.getPathInfo(); |
|
90 |
System.out.println("original pathInfo: " + s); |
|
91 |
s = this.lastPathElement; |
|
92 |
System.out.println("new pathinfo: " + s); |
|
69 | 93 |
return s; |
70 | 94 |
} |
71 | 95 |
} |
Also available in: Unified diff
fixed a bug with trailing slashes