• Post Reply Bookmark Topic Watch Topic
  • New Topic

storing the image file in the context folder

 
Sivaraman Lakshmanan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai all,
I am using JFreechart to display chart in browser using JSP. All the file produced by the jfreechart r stored in the local temp dir. if i access the page remotely i was not able to see any image file. so how do i save all my image file to the context itself.
If I give request.getContextPath(), i was not able to save it since it throws filenotfound exception.
pl help me out in this problem.
thanx,
L.sivaraman.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String fullFileLocation = getServletContext().getRealPath("myimagefilename");
then just write it out as normal using the string
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't add the generated file to the app context folder hierarchy. That could cause problems when updating your web app, especially if you are depoloying from a war file.
But apparently wherever you are storing the file is not web-accessible.
I'd create a folder for these files outside of the web app, but somewhere where either Apache or whatever web server you are using can access them.
bear
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An excellent suggestion and I'd just like to add that you could specify this location as a context parameter in the web.xml file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!