开发者

Getting Context path

开发者 https://www.devze.com 2022-12-16 06:13 出处:网络
I am developing a dynamic web project j2ee web application using eclipse. I have an existing jasper report file in .jrxml format found in web-inf/jasperreports folder. How do I access these files from

I am developing a dynamic web project j2ee web application using eclipse. I have an existing jasper report file in .jrxml format found in web-inf/jasperreports folder. How do I access these files from my java classes in the src folder. I am not even sure if context path is the right term for the root folder of the application so please enlighten me too on this part.

开发者_Python百科

I am using by the way spring webflow. how do i get or initialize the object servlet context


ServletContext.getRealPath method can be used to get the context path. ServletContext.getRealPath("/") returns the webapp root path. Path for WEB-INF/jasperreports would be:

ServletContext sc = getServletContext();
String reportPath = sc.getRealPath("/WEB-INF/jasperreports");

You can initialize you java classes from a Servlet of ServletContextListener where you can get reference for ServletContext by respectively the inherited getServletContext() and the servletContextEvent.getServletContext().

0

精彩评论

暂无评论...
验证码 换一张
取 消