Faber Siagian

Ranch Hand
+ Follow
since Jul 08, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Faber Siagian

Dear Ranchers,

How can I develop an Java application, which is flexible and able to accept and play any plug-in. A plug-in represents a business process.
For example, Netbeans or Eclipse.

With these IDEs, we can select plug-in we want to use, install, then it works together with the previously installed plug-in.

Is good Design Pattern enough for this? Or there are some issues related to technology?
16 years ago
Actually I expect this scenario :

After the user's request completed, the stateless session bean instance is moved into pool thus the value of counter reset. This is the real "stateless" session bean to me.

Originally posted by Jothi Shankar Kumar Sankararaj:
Since your refreshes are spontaneous, the instance is not requested from the pool everytime and the same instance serves you the result which gets incremented each time you refresh. Use a timeout method and return the instance to the pool and then refresh the page again and you will find that it again sarts with 0.



So you said that an instance of stateless session bean will be stored in the pool?
I read a book who says that stateful session bean will be stored in a pool meanwhile stateless won't. Correct me if i'm wrong.
Dear Ranchers,

I have a simple program to show the difference between stateless and stateful session bean :

Business Interface :



Bean Class :



The idea behind code above is returning counter from EJB to servlet and display it by using JSP.
Because the bean class is stateless, I expect the counter will always zero, just as
stateless session bean does not maintain a conversational state with the client.

But the result shows something different. The counter gets incremented each time I refresh the page.

Would someone explain what's wrong here ?
i will check it out. By the way thanks Bear for your help.
16 years ago
JSP
Just want to try finding an attribute in the request scope, instead of page or session or application scope.
16 years ago
JSP
I've created a simple Expression Language example :



The servlet already set an attribute named "person" and its value is a bean object. Also, the request
is already forwarded to the jsp correctly.

But unfortunately, the result is not what i expect. The browser gives me :

Person name is : ${requestScope["person"].name}

Did i miss something here ?
16 years ago
JSP
Actually i missed something.
A servlet instance will be destroyed if the servlet container is shut down or the container frees up the memory.
16 years ago
JSP
ok let me tell you about how do i look this case.

The value of count will be increased though i open more than one window, because every request is handled by a thread, with the same servlet.

Next..
I think the servlet instance will be destroyed if all of the request is processed completely. So when i close all of the browser, then i open a new one, count's value should be reset to zero.

But actually the value of count still continued even though i close the browser. Here where i get confused.
16 years ago
JSP
Dear ranchers,

From Head First Servlet and JSP i know that a JSP will be translated to be a Servlet by the container.

And I tried the example :


I refreshed the page, the count got increased. This is normal.
But when I open a new window and open the jsp page, the count continued, while i expect it reset to zero.

And the most confusing part for me, the count still continued even i close the page.

Would someone explain to me about case above?
16 years ago
JSP
If the value of s is 200,
there should be two objects eligible for GC, they are s and g.
g2 is not eligible, because there's no object g2 instantiated, nor it refers to an object.
oops, apparently my understanding is wrong about this.
thanks guys for pointing out the right thing
I say, there's no correct choice.
at the line #8, the current thread releases the lock, then it enters the blocking/waiting state.
And the important thing here, there's no another live thread who acquire the lock. So there will be one thread's id printed.

Somebody correct me if i'm wrong.
Let's discuss for what happens in the line #2.

When invoking method or accessing variable from an instance, the compiler always looks at the reference variable.



Here, the compiler looks at the Circle, whose getValue()'s return type is Object. So in the line 2 you have to perform explicit cast.
The value of d is rounded, just like the Math.round(double value).
If you change the code :



then the result must be 456.579