• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

delete files in JSP >>>>>>>>>>>>>>>>>

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a third party package to dynamically generate graphs which are then displayed inside my jsp. The graphing tool creates the graph as a file. We need to delete these graphs after they have been displayed. I tried doing so, but when I run the following code, my jsp does not display the graph; it just displays the box indicating an image belongs there.
. . .
<%
// generate the graph and store it to /graphs directory
%>
<img src="/graphs/graph.gif">
<%
File deleteFile = "/graphs/graph.gif";
if (deleteFile.exists())
{
deleteFile.delete();
}
%>
. . .
Can someone verify my theory here? I believe the graph is not displaying because the java code inside a scriplet in a JSP executes before the HTML is rendered to the browser. Therefore, the file is created and deleted before the <img src=". . ."> is executed in HTML.
If someone could please verify this, and if you have any ideas how to do this, I'd appreciate it. Right now, I'm guessing our only option is to run a script each night to delete the contents of the /graphs directory.
Thanks in advance.
 
Saloon Keeper
Posts: 24863
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't "execute" HTML tags like < img > - the page is sent to the client and the client then sends back requests to retrieve the < img >'s and other linked objects. So yes, the file is LONG gone!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic