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.
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.
Loudly announcing something is true and finding out you're wrong makes you feel foolish.
Finding out you're wrong and refusing to admit it makes you LOOK foolish.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop