This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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

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??

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32507

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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

Joined: Jan 10, 2002
Posts: 63225

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]
Have you checked out Aspose?
subject: How to display image based on the time ?
It's not a secret anymore!