JSP page display wrong time when compared to the server time

Hi,
This problem seems to weird but it is happening
I have web application running where time is displayed in the page. In this application time is very critical. Currently, time is an hour behind the orginal time.
I checked the server it is displaying proper time.
As a matter of troubleshooting, I wrote a java program and run the program in the same server, where the application is running. The java program returns me proper time , but JSP is still displaying time an hour behind. To trouble shoot further, I created a test jsp page to just display the time and accessed the time and the jsp displayed wrong time as well, an hour behind.
I am running[ tomcat 4.0.3 and j2sdk1.4.3 in suse linux enterprise server 9.0
My Java program
import java.util.*;
import java.text.*;
public class TestDate
public static void main(String s[])
     try{
          DateFormat DF = new SimpleDateFormat( "dd/MM/yyyy");
DateFormat DT = new SimpleDateFormat("hh:mm aa");
          SimpleDateFormat fmt=new SimpleDateFormat("HH.mm");
          Calendar cal= Calendar.getInstance();
          java.util.Date dt=cal.getTime();
          String curdt=DT.format(dt);
          System.out.println("Server Time" + curdt + "\n");
          int hh = cal.get(Calendar.HOUR);
          int mm = cal.get(Calendar.MINUTE);
          int aa = cal.get(Calendar.AM_PM);
          System.out.println("Time" + hh +":"+mm+":"+aa+"\n");
     }catch(Exception e) {
     e.printStackTrace();
This display Time3:30:1
My JSP Page
<%@ page import="java.util.*,java.text.*"%>
<%
Calendar calen;
calen = Calendar.getInstance();
int hh=calen.get(Calendar.HOUR);
     int mm=calen.get(Calendar.MINUTE);
     int aa=calen.get(Calendar.AM_PM);
%>
<%=hh%> <%=mm%> <%=aa%>
This display 2 30 1
When I run Date in linux server it gives 3:30 PM EST 2004
I am really confused, why this is happening, If you have any solutions or idea please post the solution.

My guess is that the weirdness is caused by Daylight savings time.
I will presume that you and the server are in the same timezone :-)
Alternatively it could be caused by getting a different Locale.
Try the following
Print out "date.getTime()" value (ie long representing number of millis)
They should be the same (or close) in both the app and in JSP
Try simple date format in your JSP as well - what does that result in?
Print the calendar object, and look for the difference.
It might be in Locale, Timezone, or whether DST is set or not.
Hope this helps,
evnafets

Similar Messages

  • Tomcat 4.1.24 : JSP page displayed blank in browser

    Hi,
    I am facing a problem where a blank screen is displayed to the user in browser even though the JSp page is getting executed successfully on my Tomcat server. The application and catalina logs show no errors / exceptions, still blank screen is displayed to the user sometime. If the user clicks on browser back button, the request is processed again and the page content is displayed properly.
    I am using JDK 1.4.2_09 with Tomcat 4.1.24 on Windows 2003 server.
    Is it to do with JSP:Forward mechanism? I forward the request from one JSP to second JSP and this second JSP gets executed on server but shows blank screen.
    Requesting for help.
    Thanks in advance.
    Thanks and Regards,
    Amit Paliwal

    Hi Alisha ,
    Thanks for reply. I can not put any debug message at online page,my problem is that i can not simulate the same senario at my development site.
    Amit Paliwal

  • [SOLVED] Arch displays wrong time - 2 hours forward

    Hi.
    After package upgrade today and reboot, my clock displays wrong time - it's going 2 hours too fast.
    I didn't changed anything in rc.conf. BIOS clock is fine.
    I us localtime, timezone: Europe/Warsaw.
    How can I repair it?
    EDIT: I just used date to re-adjust my clock.
    Last edited by weakhead (2009-08-26 13:37:59)

    Same Problem, solved by setting "localtime" instead of "local" in rc.conf.
    I don't know what changed because it worked before. Maybe an update in scripts that did recognize "local" but doesn't anymore ?
    ++ B.
    EDIT : [2009-08-24 13:37] upgraded initscripts (2009.07-3 -> 2009.08-1) that may be caused by that initscripts update !
    EDIT 2 : It is the initscripts, I did not see I had a pacnew rc.conf
    Last edited by maxi_jac (2009-08-28 09:59:56)

  • How to avoid the page to move up when I click the button on the Tableview?

    Hi, EP fellows.
    I currently have 3 tableViews and 1 header form set in one jsp page (I know, it may not be a good design to put three tableView in one jsp page.....but for the sake of avoiding client side eventing between each tableViews..I combined them into one jsp page). I set the Load/Navigation value to be URL. 
    Here is the problem. Everytimes I click on the Navigation button (Up/Down) to navigate the tableView data to another page, the whole page will move up and away from the table that I navigating.
    I know it is bacause the page get refreshed, and go to the first item of the page. In this case, how do I avaoid the page to move up and away form the tableView? As it is really look bad when user click on the button, they have to scroll back to the tableView they click.
    Thanks for advices.
    Kent

    As far as i remember,this javascript function pops user a dialog to save a file:
    javascript: document.execCommand('SaveAs','1',null);
    But i m not sure will it pop up for pdf, just try to google javascript to save a pdf file.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • HI Team, Recently One week back I bought a new iphone 5 from India. They have given me a used mobile which has a different IMEI number when compared to the IMEI number present on the box. Please let me know how to proceed further

    HI Team, Recently One week back I bought a new iphone 5 from India. They have given me a used mobile which has a different IMEI number when compared to the IMEI number present on the box. Please let me know how to proceed further

    When you went back to the place where you purchased this phone, & asked them, what did they say?
    No one here can help you with this, nor can/will Apple. You need to take this up with whoever you purchased this phone from.

  • Firefox no longer loads home page or deletes cookies. I have repeatedly checked both settings and they are correct. It always goes to the last page I was on when I closed the browser ..

    Firefox no longer loads home page or deletes cookies. I have repeatedly checked both settings and they are correct. It always goes to the last page I was on when I closed the browser .

    Go to '''TOOLS''' then''' OPTIONS''' then in '''GENERAL''' panel in '''STARTUP '''session choose '''Show my home page''', then click '''OK''' to save it, exit firefox and restart-it.
    see for more info: [https://support.mozilla.org/en-US/kb/Options%20window%20-%20General%20panel Options window - General panel]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • I have a problem with my iPhone 5 stopped working the sleep / power and simultaneously refused to obey the HOME button. I can not use either one or the other. I can not enable or disable the device, display lights up when you plug the charger. same displa

    I have a problem with my iPhone 5 stopped working the sleep / power and simultaneously refused to obey the HOME button. I can not use either one or the other. I can not enable or disable the device, display lights up when you plug the charger. same display works fine as it is surprising. or maybe someone knows what is the reason for this? is there any way to solve this problem?

    More than likely its a hardware issue, I have never encountered such a problem and best bet is to just go get it replaced. If you have insurance on your device apple will replace it as long as there was no water damage, if you dont have insurance they will charge $200 more or less. Hope you get it fixed

  • I am getting the error "We're sorry we cannot complete your request on the iTunes store at this time. Please try again later." on both my iPhone and iTunes on my computer. What is wrong with iTunes? Is the server down???

    I am getting the error "We're sorry we cannot complete your request on the iTunes store at this time. Please try again later." on both my iPhone and iTunes on my computer. What is wrong with iTunes? Is the server down or what? I need to download some things and update some apps...

    I've been getting the same message for like an hour now.  Since everything was working fine a few hours ago, and nothing changed on my end before it stopped working, I'm guessing it's something on Apple's end.  They probably already know about it by now, and are hopefully working on fixing it, so there's probably not much we can do but wait for them to fix it.

  • What are the advantage of using Oracle Database when compare to SQL SERVER

    Hi all
    Please tell anyone about
    what are the advantage of using Oracle Database when compare to SQL SERVER
    Thanks in advance
    Balamurugan S

    user12842738 wrote:
    Hi,
    There are various differences between the two.
    1. SQL Server is only Windows, but Oracle runs on almost all Platforms.
    2. You can have multiple databases in SQL Server, but Oracle provides you only one database per instance.Given that the very term 'database' has s different meaning in the two products, this "difference" is absolutely meaningless.
    3. SQL Server provides T-SQL for writing programs, whereas Oracle provides PL/SQLWhich means what? Both products have a procedural programming language. They named them differently, and the languages are not interchangeable. Means nothing in comparing the features/strengths/weaknesses/suitability to purpose.
    4. Backup types in both are the same. (Except Oracle provides an additional backup called Logical Backup.)You make that sound like "Logical Backup" is something more than it is. It is nothing more than an export of the data and metadata. Many experts don't even consider it a backup. I'm sure SQL Server provides the same functionality though they probably call it by some other name.
    5. Both provide High Availability.Well, I guess they both have a suite of features they refer to as "High Availability". But what does that really mean? The devil is in the details. Remember, the two products don't even agree on what constitutes a "database".
    6. Both come in various distributions.???
    >
    If you are going for an Implementation, you can try SQL Server Express Edition and Oracle XE which are free to use.
    Then you can choose whichever is comfortable for your needs.
    Thanks.

  • I bought Pages on Appstore, but when I quit the soft Pages, I get a window saying my test period has expired, and propose to buy it. I tried to install again in appstore, but same result - thanks

    I bought Pages on Appstore, but when I quit the soft Pages, I get a window saying my test period has expired, and propose to buy it. I tried to install again in appstore, but same result - thanks

    It used to be that to update the trial to the licensed version with the box, you just inserted the DVD & ran the installer to convert the trial to licensed. This changed with Snow Leopard. You now need to delete the trial & then reinstall from the boxed DVD or the Mac App Store. The files to delete are the iWork ’09 folder from the main HD > Applications; the iWork ’09 folder in HD > Library > Application Support & the individual iWork application plist files found in HD > Users > (your account) > Library > Preferences for each user.
    Yvan Koenig has written an AppleScript that removes the files. You can find it on his iDisk in For_iWork > iWork '09 > uninstall iWork '09.zip.

  • IPad2- Safari cannot open the page because it could not connect to the server? Internet works but this message continues to pop up. My iPhone works fine and iPad has been working great until a few days ago.

    IPad2- cannot open page, Safari cannot open the page because it could not connect to the server? Internet works but this message continues to pop up. My iPhone works fine and iPad has been working great until a few days ago.
    Message is almost acting like a pop up.

    Hi
    I constantly get same message.  When I open up my windows laptop all works fine so I guess it's a bug that apple refuse to admit to.

  • "safari cannot open the page because it could not connect to the server"

    As stated above. I have had this problem for the last 2-3 days. I have always been able to connect to the internet over wi-fi using my iphone but this problem had persisted these few days. This is a problem because my iPhone shows that I do have connection to the internet. ( I assume this from looking at the internet signal stregth bar at the top of the screen.) My laptop and computer have no problem but the message "safari cannot open the page because it could not connect to the server," keeps on appearing on my phone whenever I try to access the internet.
         If it is of any relevance I use an iPhone 4s, reasonably new, practically 2 months. I have never had problems before this. Thank you for your help in advance.

    The connection strength icon you are referring to has nothing to do with the Internet. It simply indicates the strength of your connection to your local WiFi network. However, even when this icon appears you may not really be connected to your WiFi network.
    Your router may not have given your iPhone a valid local network IP address. To check on this go to Settings > Wifi > your network name and touch the ">" to the right to see the network details. If the IP address starts with 169 or is blank then your router didn't provide an IP address and you won't be able to access the Internet.
    Sometimes the fix for this can be as simple as restarting your router (remove power to it for 30 seconds and restart). Next, reset network settings on your iPhone (Settings > General > Reset > Reset network settings) and then attempt to connect. In other cases it might be necessary to update the router's firmware with the latest from the manufacturer's support web pages.
    If you need more help please give more details on your network, i.e., your router make, model and version, the wifi security being used (WEP, WPA, WPA2), etc.

  • My file .mov won't load (or) play when put on the server ?

    My file .mov won't load (or) play when put on the server ? Yet it works fine in my local network.
    The source in DW is = vid.jpeg and the link = vid.mov
    I opened the movie in QuickTime player and save it for the web. I pasted what was required...
    Can someone help me with this one ?

    Could be any number of things. We would need a link to the actual on-line page to diagnose further.
    Best wishes,
    Adninjastrator

  • "An error occurred when communicating with the server. Check connectivity with your administrator to determine whether further action is necessary", then attempt to approve TimeSheet.

    Kind day, colleague.
    It was required to organize a statement chain for TimeSheet of employees, as we realized. Everything is good, but at linear managers in PSW opportunity to execute Approve when viewing TimeSheet of the employee remained, and in attempt to approve TimeSheet there
    is a mistake.
    500 Internal Server Error
    "An error occurred when communicating with the server.  Check connectivity with your administrator to determine whether further action is necessary. "
    Accept, is carried out as it is necessary.
    It is a bug or we not correctly realized approval chain?

     issue is  related to the user booking time against a task that was past the finish/end date listed in the Project Schedule.
    To resolve the user needs to submit their time on a valid task that is still within the current reporting timeframe, or have the Project Manager
    update the task in questions so that the finish/end dates are at or beyond the submission period and then republish the project. After that, the user should be able to go in and submit their timesheet with success.
    http://patrickdrews.com/2012/09/project-server-2010-timesheet-submission-produces-an-error-occurred-while-communicating-with-the-server/
    kirtesh

  • Safari will not open on my iPad Air...."Safari cannot open the page because it could not connect to the server." There were recent updates on my iPad Air. How can I fix this problem?

    How can I correct the issue of Safari not connecting on my iPad Air? It was working great 2 days ago.....now on September 20 it is not working! I have an internet connection but Safari will not open. "Safari cannot open the page because it could not connect to the server."

    Hello Beckieor,
    After reviewing your post, I have located an article that can help in this situation. It contains a number of troubleshooting steps and helpful advice concerning network issues:
    iOS: Troubleshooting Wi-Fi networks and connections
    Follow these steps to troubleshoot the above issues:
    Be sure you're in range of your Wi-Fi router (access point).
    Tap Settings > Wi-Fi and turn Wi-Fi off and on. If your Wi-Fi setting is dimmed, follow these steps.
    Confirm that your Wi-Fi router and cable or DSL modem are connected to power, turned on, and connected to the Internet. If not, refer to your network administrator or Internet service provider (ISP) for assistance.
    Restart your iOS device.
    Tap Settings > Wi-Fi and locate the Wi-Fi network to which you're connected.
    Tap and Forget this Network.
    Try to connect to your desired Wi-Fi network.
    Note: You may need to enter your Wi-Fi password again if your network requires one.
    Turn your Wi-Fi router off and on2. If your ISP also provides cable or phone service, check with them before attempting this step to avoid interruption of service.
    Update your device to the latest version of software.
    Update your Wi-Fi router to the latest firmware2. For AirPort Base Stations, install updates using the AirPort Utility.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

Maybe you are looking for

  • ICal, MS Outlook, and Titles in published calendars

    I need to publish my calendar, and would like to use iCal to do it. However, I only need the equivalent of free/busy information to show (I don't want to show any other information about events). I thought that unchecking "Publish Titles and Notes" w

  • How to restore itunes library from a faulty time machine backup?

    Hello, I just bought a new macbook pro 15inch. I have a time machine backup but I wanted to start fresh so I didn't use the migration assistant to transfer my info. The only thing I want is my iTunes library with the playlists, ratings, artwork etc.

  • Subject in utl_smtp

    Hi we use utl_smtp to send html emails with special characters as 'ěřšý' and it works fine. can me anybody tell if it is possible to use this characters in the email subject? we use utl_smtp.write_data(c, 'MIME-version: 1.0' || utl_tcp.crlf); utl_smt

  • Help with AS to freeze bitmapdata animation

    I am using BitmapData to create an animated flag waving with Actionscript. This is for an ad, so the coded animation needs to stop after 30 seconds. I would like to "capture" an image from the animation and use this for the last frame instead of just

  • No right click context menu on tabs, just the name of the site.

    When I right click on a tab, there is no context menu, only the name of the site. What happened to the options such as "close other tabs", etc.