aspose file tools*
The moose likes JSP and the fly likes Problem with Session Scope while using with Java Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Session Scope while using with Java Bean" Watch "Problem with Session Scope while using with Java Bean" New topic
Author

Problem with Session Scope while using with Java Bean

sulthan mytheen
Greenhorn

Joined: Mar 27, 2009
Posts: 3
Ihave problem with jsp session scope.....In first page i enter name as first name then i am going to second page, in this page i
enter school name as school name....now i am going back to first page, in this(first) page the value first name is there in the text box what i typed...now i delete the value and i left that
text field as blank and i am going to second page and then return to first page...here now i want the blank text field only....but it showing the value first name what i typed at first time.
Please Let me know what and where is the problem behind that code.

I dont want the logic by setting as a hidden variables or session.setAttribute. Please Suggests me any other solution. Why the bean didnot get the value of empty string....?


Thanks in Advance....


Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Hi,

Your question is little bit difficult to understand. Explain it proper.

But What i understand I will explain first Session variable scope is your application session alive. When you enter first name and set it using session.setAtri("firstName"); then when your requirement of this variable is no longer then make it to null. other wise when you try to access again it shows old value.

So, when you come back it holds old value and you have to set it to null or new first name value.

Now you not get older value.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
sulthan mytheen
Greenhorn

Joined: Mar 27, 2009
Posts: 3
Thanks for your Reply....

I ll explain my question clearly....I have two jsp page and one javabean, both jsp files having next and previous button....now in first jsp i enter a value like first name and then i go to second page and then i return to the first page...
Now there is a value first name is available....because of i m using session scope....Ok...

Now i chanege the first page value like last name....now i go to second page and then i return to the first page...
Now there is a value last name is available....Ok....

Now i change the value last name into empty string, that is what i am saying is i leave the text field as blank.....now i go to second page and then i return to the first page...Now the first page should contain a balnk text field ....But at that time it shows me value like last name....Ok....This is what my problem.....why session variable didnt accept null value....

I think you can clearly understand my question....

Also i have attached my code for your reference.....

Kindly clarify my doubt...and give me a solution...Thanks in Advance
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Please leave way all of those dots. It reads annoying. One period at end of every sentence is enough. Pay attention to your English and overcome like a real professional.

Regarding to your question, you apparently want to keep the data request scoped, in this case you should not store them in the session, but in the request scope. If you want to pass the request parameters of the previous request through the current request to the next request, you need to pass them through hidden input elements.

E.g.

The ${param.firstname} can of course also point a javabean property, like ${beanname.firstname} but you should already understand that.
sulthan mytheen
Greenhorn

Joined: Mar 27, 2009
Posts: 3
But i clearly said i dont want the logic by setting as hiddden variables, because i have totally 3 pages and the total fileds are 120. So as per you reply, by setting as hidden variable means i have to write code for request.getparameter as well setting hidden variables for all 108 fields on all the three pages. So the code come as tedious. i want to reduce the lines of codes, so that i am using javabean and jsp:useBean with session scope concept. I have analysed the problem and i got one point which is the setter method of javabean class will not be invoked at the time of no parameter or empty string passed.

Now my point is correct or not? Is setterMethod will not called for emptyValues?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If the data is getting big, you can keep them in the session scope and create a Filter to simulate the "conversation scope" using some unique key in the request scope which you pass as only one hidden input value. Maintain the bean references in a map of unique key - bean pairs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Session Scope while using with Java Bean