It's not a secret anymore!*
The moose likes Tomcat and the fly likes How do I display local times in directory listings displayed via Tomcat 5.5.23? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How do I display local times in directory listings displayed via Tomcat 5.5.23?" Watch "How do I display local times in directory listings displayed via Tomcat 5.5.23?" New topic
Author

How do I display local times in directory listings displayed via Tomcat 5.5.23?

Chris Loschen
Greenhorn

Joined: Nov 28, 2007
Posts: 10
Hi all,

We've got an intranet web site running on Tomcat 5.5.23 which displays directory listings. We've noticed that these listings always display with the time from the GMT time zone, not the local time zone, and we'd prefer to have the local time displayed.

Is this a configuration setting somewhere? If so, where? I could set a JAVA_OPT to -Duser.timezone=EST, but I'm not sure where Tomcat sets up its JVM options, and besides, that would force a single time zone when what I really want is to display the local time whatever that might be.

Thanks for your help!

Chris
Chris Loschen
Greenhorn

Joined: Nov 28, 2007
Posts: 10
Does anyone have any ideas on this? My web searches haven't been helpful so far. Thanks for your help!

Chris

Originally posted by Chris Loschen:
Hi all,

We've got an intranet web site running on Tomcat 5.5.23 which displays directory listings. We've noticed that these listings always display with the time from the GMT time zone, not the local time zone, and we'd prefer to have the local time displayed.

Is this a configuration setting somewhere? If so, where? I could set a JAVA_OPT to -Duser.timezone=EST, but I'm not sure where Tomcat sets up its JVM options, and besides, that would force a single time zone when what I really want is to display the local time whatever that might be.

Thanks for your help!

Chris
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I looked into it with no satisfactory solution. Seems to me you need a way to get the timezone the user's browser thinks it is in. HTTP seems to insist that all timestamps are in GMT.

Furthermore, in order to use Tomcat's default directory listing with special handling of file timestamps you would have to meddle with the default servlet source code.

How about this - use Javascript or cookies or user database or something to tag the user's request with the timezone and write your own directory listing code.

Writing directory listing code is not hard and gives you the opportunity of applying your own security rules to control what the user sees, insertion of href links for downloading, etc etc.

Bill
Chris Loschen
Greenhorn

Joined: Nov 28, 2007
Posts: 10
Originally posted by William Brogden:
How about this - use Javascript or cookies or user database or something to tag the user's request with the timezone and write your own directory listing code.

Writing directory listing code is not hard and gives you the opportunity of applying your own security rules to control what the user sees, insertion of href links for downloading, etc etc.

Bill


Thanks for your reply, Bill. Unfortunately, I'm not sure my bosses would be willing for me to spend that much time fixing an app that we're only using in-house.

I'd be willing to live with forcing EST if that's easier to accomplish, since most of our users are in the EST timezone.

On that front, I saw several other places where people were suggesting adding java options to the catalina.bat (or .sh) file. My installation of 5.5.23 didn't have any such files, but I do have them from an installation 5.5.20 so could probably make use of that. However, Tomcat is running as a Windows service in my environment and those files look like they're never actually called -- instead, it calls tomcat5.exe directly.

I found a catalina.properties file in the bootstrap.jar which apparently does get called when tomcat starts up, but I don't see anything in there which allows me to set any java_options.

I suspect my bosses would prefer that I give up on fixing the bug rather than rewrite all the directory listing code, just because of time concerns.

Does that help provide any leads? Thanks again for your help.

Chris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I display local times in directory listings displayed via Tomcat 5.5.23?
 
Similar Threads
Problem with Calendar().getTime()
local time display in forum
Time zome problem, while sending Date through WebServices
ServletException: Error allocating a servlet instance
How to preload a JSP?