GetServletContext (). getRealPath ("") returns null in WebLogic

When the bottom line was done

String realPath = request.getSession().getServletContext().getRealPath("");
String imagePath = realPath/images/product/abc.jpeg;
System.out.println("ImagePath-> " + imagePath)

When I try to print the sys out line, I see that realPath returns null in weblogic as null/images/product/abc.jpeg

When I google for a solution. There are two solutions that I found: -
1.By I can manually go to the Weblogic Console → Domains → Web application → Check the archive real path (which I do not want to do)
2. I can add the entry below in weblogic.xml manually

   <container-descriptor>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>

which I added to weblogic.xmland tried to redeploy, but still realPath returns null after adding to xml files.

As soon as I try the first approach, changing the settings in the console, I see that realPath returns the correct path. But I do not want this user to make any changes.

- weblogic , , - .

+4
1

WLS12.1.3, . Oracle: ServletContext.getRealPath() - NullPointerException (Doc ID 858783.1)

, , .

0

All Articles