Am working on spring boot applicaiton. I want to write a jsp files dynamically into the web content. So i took the real path from the ServletContext and write into it. It is working fine in eclipse.
@autowired
ServletContext context
or
ServletContext context = request.getSession().getServletContext();
String targetPath = context.getRealPath("/default/pages");
But I try to deploy a war file on linux machine, the path is empty. Please help me to fix this or let me know if it possible to do ?
spring boot embedded tomcat
There are lots of reasons not to rely on getRealPath() in real-world deployments. There are several better approaches, depending on your use-case; but the one that worked best for me was to use a file path from the application.properties file using @Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With