×

Loading...

If this is an interview question, ....

Don't try to to recite definitions. A SessionBean has some methods.
If this call of a method does not leave any information for next call, it is stateless.
If this call accumulates some information for next call, it is stateful.

It is your business that decides whether to be stateful or not. For instance, if you need a SessionBean called TaxCalculatorBean, I
would like to suggest deploying it as stateless. Why? For each method call, we just need input some parameters such as quantity, states(provinces) and get a tax to be charged. The present calculation have nothing to do with next one.

I have not used EJB for some time. I remember that if one wishes to make stateless SessionBean, he needs to declare no instance variables.

"Stateless" is a word we needs to pay attention. As I was a beginner, I asked several professional programmers but they gave me wrong explanations. Maybe because we are not native-English speakers.
Report