Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing listeners

 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our app (built using servlets & jsps) runs on an application server. I have a situation where I need to know if a file is present in a particular location. This file is created after the user logs on and it will be posted in a certain location. I'm trying to implement a listener so that I can give the file to the user after it has been created and posted.
Any ideas on how to to achieve this? Also, if you have any questions, please let me know.
Thanks in advance,
Srinivas
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can create a thread that sleeps most of the time, but every second/minute/hour/whatever wakes up and looks for the file. You can check for a specific file name, or use File.listFiles() combined with File.lastModified() to search for any new files in a particular directory.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use java.util.Timer and java.util.TimerTask to do as Jim has mentioned.
Or you can use Oberver and Observable Pattern.
Garandi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic