Changing source code doesnt reflect in the program output. Can you handle it?

Yes, you read it right. And it happened to me recently. If you have also faced it at some point of time, may be this article will help you understand some development intricacies you were not aware of.

I was recently working on a company project, coding my application in JSP. I added a line to the code, which was supposed to give a nice looking title to the page. I made the changes to myfile.jsp and hit F5 on the browser window (where myfile.jsp was open).

The heading did not appear. It appeared as if the page had somehow “forgotten” that it has to check for updates in the source code while reloading the browser window. Initially I thought it was a browser cache issue. So I meticulously cleared all my cached files, cookies, authenticated sessions etc.

Again hit F5 (Refresh). Still no change. Now I was starting to get puzzled. May be my source code is at fault, I thought. May be I used tags which will not render any output. Checked that. Again F5. No luck.

I left for lunch.

As I returned, I recalled something I did on my computer that day morning. And by the very little I remember from my college studies, I was almost sure that those things were somehow related. Here is what I did:

In the morning, I saw my system date/time settings. Although the actual date was 20 December 2007, my system was showing the date as 21 December 2007. I casually changed the system date to 20th. Little did I realize how big a mistake this could be.

(In general, I have read that it is not a good idea to go back in time. If your clock is running ahead of time, technically it’s better to “slow it down” till the actual time and indicated times match. But I am not sure if “slowing the clock” is an option in Windows XP.)

Here is how it made the difference:

JSP pages are compiled on the fly. Which means that your code will be compiled at the time when you call it the first time from your browser. Since the changes in my JSP source file were not getting reflected in the output, it was obvious that the code was not getting compiled. The browser was still showing me the output from the previous compile.

Why?

Here is why: Whatever changes I made in my file before adjusting my system date were recorded as “Last changed on 21 December 2007”. Now when I changed my system date, all changes I was making in the code were being recorded as “Last changed on 20 December 2007”.

So even though the source code was changing, the system was picking up the last changed date as 20 Dec and comparing it with the date/time stamp of the compiled file (21 Dec). Since 20 Dec < 21 Dec, it concluded that the compiled copy is more fresh compared to the last edited file, and hence there is no need to compile the source again. The next challenge –

Since you are working on the same file everyday, what do you do to make the system date/time come to normal and still make sure that your code compiles?

Guess guess.
If you can’t figure out, here’s a clue: Weekends.

Still clueless? Leave me an email and I’ll tell you a simple fix, which I figured out.

Also read...

Comments

  1. Here it is:

    Assuming that you don’t work on your computer on weekends (atleast not on the JSP code), move your system date to 2 days ahead (i.e. to the date on Monday) when you are about to leave work on Friday.

    When you return to work on Monday, before you start work, correct the system time and make it the actual date/time for that day (bcoz by then, sys time would have been showing Wednesday).

  2. Here it is:Assuming that you don’t work on your computer on weekends (atleast not on the JSP code), move your system date to 2 days ahead (i.e. to the date on Monday) when you are about to leave work on Friday.When you return to work on Monday, before you start work, correct the system time and make it the actual date/time for that day (bcoz by then, sys time would have been showing Wednesday).

Comments are closed.