Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   ApplicationDispatcher.requestURI starting with two slashes (http://www.velocityreviews.com/forums/t735842-applicationdispatcher-requesturi-starting-with-two-slashes.html)

Peter Horlock 10-18-2010 04:39 PM

ApplicationDispatcher.requestURI starting with two slashes
 
Hi,

we have written a litter filter that rewrites incoming request, as
well as by using a response Wrapper object that will rewrite the
encodeUrl Methods so that outgoing urls will also be rewritten.

So the code looks something like this:
String rewriteURL = createRewriteURL(request);
RequestDispatcher forwardDispatcher =
request.getRequestDispatcher(rewriteURL);
forwardDispatcher.forward(request, toRewriteResponse(request, new
ResponseWrapperClass(request, response)));

This code works perfectly under some context path, lets say
"server:port/example/...
However, when run on the context root "/", it fails.

I also found a / or "the" bug, in the forwardDispatcher object, when
debugging, the private requestURI attribute
starts with two "/" slashes instead of just one. Example:
"//MyPage.html"

---------
request.getRequestDispatcher(rewriteURL) is handled internally by
Tomcat code, but by manually adding some of it's source code, I was
able to debug into the following lines of code that get called when
request.getRequestDispatcher(rewriteURL) is called:

public class ApplicationContext
implements ServletContext {
[...]
private ThreadLocal localUriMB = new ThreadLocal();
[...]

public RequestDispatcher getRequestDispatcher(String path) {
[...]
MessageBytes uriMB = (MessageBytes) localUriMB.get();
[...]
CharChunk uriCC = uriMB.getCharChunk();

[...]
return new ApplicationDispatcher(wrapper, uriCC.toString(),
wrapperPath, pathInfo, queryString, null);
}

When the Dispatcher is created, the uricCC.toString() contains the two
slashes ("//").
------------
However, where do they come from? What's going on here / what's going
wrong here? I am really confused, sorry!

Thanks in advance,

Peter

Peter Horlock 11-16-2010 02:11 PM

Re: ApplicationDispatcher.requestURI starting with two slashes
 
Problem solved. It was a problem with the Eclipse Tomcat Plugin! :-(

Lew 11-16-2010 11:57 PM

Re: ApplicationDispatcher.requestURI starting with two slashes
 
On 11/16/2010 09:11 AM, Peter Horlock wrote:
> Problem solved. It was a problem with the Eclipse Tomcat Plugin! :-(


Thank you, I'm sure that information will be very helpful to the next person
who faces this issue.

Kidding aside, would you mind terribly sharing just a little bit of detail so
the rest of us may benefit?

--
Lew


All times are GMT. The time now is 02:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57