I have a Spring Controller having bla bla code along with the bellow line of code.. i wrote a TestCase for the respected Spring Controller by using MockHttpServletRequest,response,session. every thing is working fine except the bellow line.
I am getting "null" in my controller when i call it from the TestCase class.
How to get the "realPath" through the MockHttpServletRequest.
If any body know about it please give me a response... thanks in advance...
What exactly is null? session or servletContext? I'd say the latter. Are you using MockServletContext? In which case, your context will change and you might not have a"pages" directory under the mock context root.
Googling doesn't make you a genius. But not Googling makes you dumber.
Joined: Sep 21, 2009
What exactly is null?
my answer is like bellow
if the above line executes as a normal request through application no issues.
if the above line executes through the Spring Unit Testing MockHttpServletRequest i am getting null.
still if you are not getting my problem. i am very sorry please refer this url
getRealPath is a very dangerous function. It will return null anytime that there's no filesystem path to the requested resource. If you deploy a webapp on a server that doesn't "explode" the WAR (unzip it), the "files" in the WAR won't be actual filesystem files and they won't have realPaths.
An IDE is no substitute for an Intelligent Developer.