This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Datetime taglib  RSS feed

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded the jakarta datetime taglib, and am able to use it well enough.
My problem is, I want to be able to show what the current date is for the client. However, since the server is in England, it keeps showing the date for the server. Is there a way using this taglib to do this (hopefully someone has used it before), or any other way to use jsp's to show the client's date, not the vm's running on the server?
Thanks!
Jason
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, I have no idea.
JSP's are server side components, as you might agree with me. I would assume
1. you probably must use some kinda Javascript for this.
2. A cookie/header maybe but not the accurate client time. This would probably give you request date and time, maybe.
3. Not sure how, but a lot of webpages do this.
Never tried any of these, but that would be my first guess.
Interesting problem, though.
regds.
- satya
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This really has nothing to do with server-side vs. client-side processing. Most date/time facilities make allowances for different locales and timezones. I haven't had a chance to check out the taglibs yet, but I can't help but think that locales and timezones must be accounted for in some way. Check the docs for the taglib for these topics.
If this is the case, obviously the client must inform the server-side software of the appropriate locale and timezone to use. But there's no reason that server-side software cannot handle any locale and timezone.
hth,
bear
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does have options for setting locale and timezone, which I tried utilizing. Locale is used for formatting and parsing of a date String, and from what I read of the timezone tag, you would use this to gather a list of available timezones, and then the client or whoever would choose the one appropriate to them.
What I'm trying to figure out is how does the client automatically tell the server what timezone or locale they are in, so that the date reflects that. Making a drop down list for them to choose from is easy enough, it's the automatically configuring at page start up that is a pain.
Whether I use the taglib from jakarta or not is not an issue, I'd like to find any way a JSP can do this.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Locale's are available on the Request Header.
But remember, I can be in Japan and use a German/Chinese locale. So I don't think locale is what you want.
Check the getDatHeader() method of the HttpServletRequest interface. See what it returns.
regds.
- satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!