Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching an image...design question.

 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet that reads up imaages from a databasae and sends them back to my web app. If a requested image does not exist, I send back a common default image.

My question is about caching this default image.

Is there any problem with making an ImageIcon static, and checking to see if it contains data (is null or not), and if it does hold data, just return its contents, and if it is null, have it read up the default image for the first time?

Need I lock this "null check" code down or should it be "OK" not to do so since it is a static object that will be set to the same value regardless?

Thanks!
[ June 30, 2005: Message edited by: Darrin Smith ]
 
leon fan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so if you properly design that class. I guess you still need class lock for you function in which you will create your default icon.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd consider reworking the solution to allow a static image to be served rather than hitting the servlet, if possible. When you build the initial page, change the image location to the servlet or an image on the file system if that servlet image doesn't exist, it'll be worth it in the long run.

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic