use req.getContextPath to find the RootUri.. much more robust. 4.0 and 4.1 compatible...