• Post Reply Bookmark Topic Watch Topic
  • New Topic

object instance

 
Rafael Fagundes
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
In a jsp page i have the source code bellow:
if(request.getParameter("obj")==null)
{solti = new YYY.SolicitacaoTI(); }
With this object i full fill some fields of this page. In the first try, everything ok. But when i visit this page for the second time, the fields have the same information off the last time. Therefore, a new instance of this object it�s not created...why?
PS:
<jsp:useBean class="YYY.SolicitacaoTI" id="solti" scope="session"/>
However, i think that�s not the problem because i have another jsp page with the same procedury but with a diferente scope (request) and the same problem it�s happening....
What�s wrong?
PS2: Tomcat 5.0
Thank�s for your attention
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
410
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rafael,
You are very close to the problem (session vs request.)

When an object is stored in the request, it is deleted after each page load. So when you hit the page a second time, the object is gone.

However when an object is stored in the session, it stays there until the session times out or is invalidated. So when you hit the page a second time, the object is still there.
 
Rafael Fagundes
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Rafael,
You are very close to the problem (session vs request.)

When an object is stored in the request, it is deleted after each page load. So when you hit the page a second time, the object is gone.

However when an object is stored in the session, it stays there until the session times out or is invalidated. So when you hit the page a second time, the object is still there.


Thank�s a lot, you opened my eyes, hehehe
I was getting a problem when a used the scope request to the bean but it�s solved now...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!