• Post Reply Bookmark Topic Watch Topic
  • New Topic

StateFulSessionBean Problem  RSS feed

Ajit Kumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using VisualAge for Java.
Here is the client servlet code that is using the stateful session bean.
public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
PrintWriter out=response.getWriter();
studentsfsHome studentHome = null;
studentsfs student= null;
try {
java.util.Hashtable env = new java.util.Hashtable();
env.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
javax.naming.InitialContext ctx = new javax.naming.InitialContext(env);
studentHome = (studentsfsHome) ctx.lookup("main/studentsfs");
studentsfs studentRemote = (studentsfs)PortableRemoteObject.narrow(studentHome.create(),studentsfs.class);
String option=request.getParameter("userid");
if (option==null){option="";}
if (option.trim().length()==0){
out.println("userid : <form action=http://localhost:8080/servlet/main.testsf method=post>" +
" <input name=userid><input type=submit></form>");
if (option.trim().length()!=0){
out.println("password : <form action=http://localhost:8080/servlet/main.testsf method=post>" +
" <input name=password><input type=submit></form>");
if (option.trim().length()!=0){
out.println("Final Details are : " + studentRemote.getDetails());

catch(Throwable theException)
catch(Throwable theException)

-The servlet displays an empty form with one text box for userid
- the servlet is getting called when the form is submitted.
- i am creating an instance of the stateful session ejb and setting (setUserid) the userid field in that ejb object.
- after calling this method, the servlet displays another form with one field for entering the password.
- when the user submits this form, the same servlet gets called and the servlet again creates an instance of the same stateful session bean and sets the password (setPassword).
- and the servlet displays the userid and password information through another method call getDetails of the statefulSession EJB.
- Since this is a stateful session bean, which is supposed to maintain the state internally, it should print
the entered userid and password values...
- but the ejb object is not retaining the first userid value.
I would like to know:
- if there is anything wrong in the way i am using the stateful session bean.
Any information in this regard willbe greatly appreciated.
thanks in advance.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!