This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to use sessions in shopping cart like application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to use sessions in shopping cart like application " Watch "how to use sessions in shopping cart like application " New topic
Author

how to use sessions in shopping cart like application

vaibhav srivastava
Greenhorn

Joined: Mar 17, 2008
Posts: 23
Suppose we have a page "A" where we can enter any string in text field and on submitting this string has to be saved somewhere to retreive later and this page "A" again pops out to enter any new string.This process continues until we press END button on the page "A" and we can retreive all the string stored earlier and print it as a bill with tabulated index like each string as a seperate index.
Eg.
1)abc
2)pqr
3)xyz

I dont want to store these strings in a database and after printing bill this session should be invalidate.


Regards <br />vaibhav srivastava<br />SCJP1.5 , SCWCD1.5
Jilesh Lakhani
Ranch Hand

Joined: Jul 26, 2006
Posts: 49

Well, yes.. you can do that..
session.setAttribute("inputItems","value");
and now when it comes to update this values again check if you have the details in the session already,
if yes then well use your logic simple would be String concatenation, else adding it some Array or class and saving that in session.
and while printing say
session.removeAttribute("inputItems"); and you are done.


-Jilesh
Universe and Knowledge has no bounderies
vaibhav srivastava
Greenhorn

Joined: Mar 17, 2008
Posts: 23
Thanks Jilesh

I understood your point But can you be bit elobrate about the logic portion used.
Jilesh Lakhani
Ranch Hand

Joined: Jul 26, 2006
Posts: 49

Something like,
Session.setAttribute("inputValue","value1");
next time you add values there
you can do something like
session.setAttribute("inputValue","value1|value2");

next option can be like,
session.setAttribute("inputValue",[value1]);
and then when the user enters new value can update the session value to
session.setAttribute("inputValue",[value1,value2]);

or you can also try using your own Data Structure,
so, experiment and Enjoy!!

Personally I wont go with the first option though thats simple but that's bound to throw errors.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use sessions in shopping cart like application
 
Similar Threads
directory retreival
Building JTree - Like Object
How to Retreive Meta-Tags
login into administration
retreiving the users in ldapserver