• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to give relative path to file  RSS feed

 
pradeep gamage
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing jasper report. So i have created abc.jasper file by using iReport. Then i have put it into /WEB-INF/reports/ . Then I have loaded abc.jasper file as below. but it doesn't work.


if I put Exact path intesed of Relative path above code is working fine. So Can any one suggest me how to load abc.jasper file by giving relative path?

Thanks in advance
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are putting this into WEB-INF then perhaps you are going to deploy this as part of a war file?
If so then you could put the .jasper files on the classpath and use Class.getResourceAsStream to load them as resources.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or simply use ServletContext's getResourceAsStream method. This allows you a little more flexibility about where inside the web application you put the resource without having to set any class paths.
 
pradeep gamage
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for valuable reply.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!