Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

ben oliver

Ranch Hand
+ Follow
since Mar 28, 2006
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ben oliver

Suppose we have two servlets runing inside same war on same server. When user access servlet A and create a session, he then open another tab or browser to access servlet B (session created by servlet A still exist). Inside servlet B, does


return the session created by servlet A ?

3 years ago
when I said "data change on the server", I meant the data is changed on the server side (not because of ajax call). sorry for the confusion.

Bear Bibeault wrote:

Amar Saikia wrote:Yes. It will.

No, it won't. Data changing on the server will in no way be automatically reflected on the client.

I guess I get it --- In old JSP approach, you have to repload the entire page to get updated server side data. But for ajax, you may use some event (click a link, expand a section ,etc) to trigger ajax call to load some server side new data without loading the entire page, only that portion of page will be refreshed. Correct ?
Ok. javascript makes ajax call and load json data on page, fine. Now my question is --- suppose a section of page <div> uses javascript to make ajax call to get data, if the server side data changes, does this section of page gets refreshed automatically ? If not, what's the advantage of ajax ?
I heard jQuery (or dojo) can make ajax call (xhr) to server to get json data and display them on the page.
But this thing can be done using jsp too (jsp cna get java bean and render it on page). What's the difference and advantage of jquery or dojo call ?

Another question --- when the data on server side changes at real time, does the page written in jquery or dojo ajax call get them instantly without
having to load the entire page ? if yes, how ? how can the ajax call keep happening all the time by itself ?

Please give some conceptual clarification help. Thanks !
In the middle of a java code (class A), if I need to invoke another java class (class B) , which has its own logics there and some database process taking lot of time. It will hold my java class A execution because it is doing it sequencially in class A. How do I let that calling class B happen async so that class A can continue ? The pre-condition is -- class A does not depend on the result of invoking class B. How can that be implemented ?

4 years ago
If I have a class like

Given a list of Students I need to sort using different attributes like "name", "address", "enrollDate", etc. Each has a different comparison rule. One approach is to create several different Comparator classes, each implement its unique compare method. Is there any better way that I don't need to create several comparator classes but still can sort the Stuent List using whatever attribute ? i.e. is it possible to consolidate the multiple comparator classes into one ?
5 years ago
Anybody knows any good resources to learn Java J2ee selenium testing ? Any good book, web site ?
5 years ago
bear with me. Is it true that, regardless of time zone, the "c.getTimeInMillis()" always returns the same value no matter what time zone you use ?
5 years ago
Thanks for the replies. Yes, I missed setting the time zone for SimpledateFormatter..

One more question --- After I do Calendar c = Calendar.getInstance(), I can associate different time zone with it. But when I pass this Calendar instance "c" to some other method, it really does not matter what time zone I has set for "c" before I pass it to that method, correct ? The content of "c" is the same regardless of the time zone it is set for, correct ?

5 years ago

Paul Clapham wrote:Like I said... set the timezone of the Calendar to the timezone for US Eastern time (I think its name is "America/New_York"), get the hour of the day from the calendar, and see if it's greater than or equal to 14.

Paul, I am near Boston, and when I run this code, I set it to CA time zone on purpose, but I still get

time = 2012-07-18-10.14.40 AM EDT

which means it still takes EDT as I am running it in East coast. it didn't take the timezone I input. Why ?

5 years ago
Paul, do you mean if I set time zone to US New York, then even if I run this code in California, it will print out the date and time in Eastern Time (ET) format and value ? e.g. if it is 2PM PST/ 5PM EST, after I set time zone to New York, it will shows "HOUR_OF_DAY" as 12 + 5 = 17 even if I run it in California ?
5 years ago
If Calendar.getInstance() returns time based on where the code is run. Assuming I run the code in USA but may run it in different cities. How do I check if the current time is later than 2PM US Eastern Time ? How do I write a code snippet that no matter where I run the code in USA it always can compare against US Eastern time 2PM ? Assuming there is no international issue, only run it in USA.
5 years ago
Calendar.getInstance() can return current time. From there you can extract the day/hour/min, etc. By default, is the hour/min it returns EST or Pacific Time or Mountain time ? What controls that ? Is it true it is controlled by where this code is run ? e.g. if you run it in CA it may give you 2PM, while you run it in NC it gives you 5PM , though you run the code at same time.
5 years ago
I just started a contractor position (8 month length) few weeks ago. I found the job is not what I expected, it is more like production support work rather than development. Another company I worked with before just told me they have a contractor opening now and it is exactly development work. But I don't know if I should go there --- I just started my new job few weeks, although it really looks boring I feel I better stay for 6 months to have a good record on my resme. But these 6 months will be really not fun at all. One friend said I should just leave.

What do you think I should do ?
5 years ago