I required your help in developing my J2ee based applicatin in which I am
using 3-tier architecture. My page flow is as following,
Login.jsp
(in which he gets id and password and create stateful session bean and pass
these parameter to SFSB business method that method calls create local BMP
entity bean and pass those id and password to entity bean business method
and then get result and return back to jsp page in that page I set two session
variable one is based on database result which we get on behalf of id and password
and other is my remote object of SFSB, then i go to next page Home.jsp)
Home.jsp
(in this page I get session objects and display some result and in this page I have a link of logout.jsp
page when user click that link it goes to logout.jsp page)
logout.jsp
(the code of that logout.jsp page is)
<%
try{
akdtradedemon.UserSesion us=(akdtradedemon.UserSesion)session.getAttribute("usersesion");
us.remove();
}
catch(Exception e)
{
e.printStackTrace();
}
session.invalidate();
out.println("You have sucessfully log out");
%>
Question:
My question in this regard is that whether I should remove SFSB here by myself it is good technique or container
should do this to me any thing about this code any suggestion or code u refer to me will be very helpful for me
please reply
From Noman Ahmed
Appxs Ltd.
-
Removing a stateful session bean from client code (2 messages)
- Posted by: Noman Ahmed
- Posted on: February 23 2005 03:25 EST
Threaded Messages (2)
- Removing a stateful session bean from client code by Bill Lasley on February 23 2005 13:17 EST
- Removing a stateful session bean from client code by ahmed tantan on February 23 2005 15:26 EST
-
Removing a stateful session bean from client code[ Go to top ]
- Posted by: Bill Lasley
- Posted on: February 23 2005 13:17 EST
- in response to Noman Ahmed
If you don't remove the bean the EJB container will passivate the bean when it needs the memory.
Passivation is a very expensive operation, particularly when the SFSB contains a number of Java objects.
Removing the SFSB frees memory by moving the bean into "Does Not Exist State". When the bean times out,
the container might call ejbRemove(), but it does not have to.
Recall that SFSBs are not pooled, as are stateless session beans. There is one SFSB for every client reference.
I suggest you reassess your design and see whether you really need to use SFSBs (and whether you need to use BMP
rather than CMP entity beans).
There are many great design and coding resources, including free books, right here on TheServerSide, that will give you guidance.
Bill Lasley
Versant Corp.
http://www.versant.com -
Removing a stateful session bean from client code[ Go to top ]
- Posted by: ahmed tantan
- Posted on: February 23 2005 15:26 EST
- in response to Bill Lasley
Hi all,
In my opinion, you need to refactor the architecure of your application. EJB code in JSP pages is not elegant, I would use the mvc pattern to divorce the layers.
the clasic architecture would be
depanding on your requirement, you may for example do :
1) jsp --> controller servlet (ie struts) -->EJB
or
2) jsp --> controller servlet (ie struts) -->DAO
I hope understood your question.
Ahmed