aspose file tools*
The moose likes Servlets and the fly likes How to display image based on the time ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display image based on the time ?" Watch "How to display image based on the time ?" New topic
Author

How to display image based on the time ?

Bhoomika Bathla
Ranch Hand

Joined: Nov 28, 2009
Posts: 40
I am working on a web portal.I need to display a chat link on the page.The specifications are as follows :-
1. Chat link should be visible to specific user -- already defined in a table.
2. If chat link is visible then there are two cases in it.Firstly if timings are between 8 am to 6pm then the chat open image should be visible,else chat close image.

I am using servlets and jsp.

How do i proceed with the solution.What flow do i need to follow to implement this??

Thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Is this only one page? If so, just use an if statement in the servlet of c:if in the JSP. If it is on multiple pages or you need to protect the chat pages themselves with the same logic, I would use a servlet filter - that way all the "is chat open" logic can be in the same place.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bhoomika Bathla
Ranch Hand

Joined: Nov 28, 2009
Posts: 40
yes this is in one page only.But it may be possible that user is using the link and suddenly the clock stuck 6 so after 6 the link should not be visible.User needs to refresh the page to do so.One constraint is that I cannot use Ajax.How should i keep checking the time and refresh the page accordingly??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

You don't need Ajax to change an image. Just change it's src attribute. You'll need to handle all this in JavaScript of course.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display image based on the time ?