• Post Reply Bookmark Topic Watch Topic
  • New Topic

I guess one way is assign it a new empty obj, how a session bean obj

 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I have in JSP the
<jsp:useBean id="AddChoosePlant" scope="session" class="beans.OrderTotals" />
as cart obj that contains lineItem objs and total vars,
then how to act to empty cart?

I guess one way is assign it a new empty obj, how?

or make session scope, page scope and redirect?

well?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One appropriate way would be to submit to a servlet, and in the servlet, empty the cart.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you mean by "submit to a servlet"?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

"empty cart" link goes to a servlet that empties the cart, does whatever additional processing is necessary (if any), and so on. Could be Ajax, too.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"empty the cart" implies data processing, so it's not an appropriate action to take in a JSP. Are you submitting a request directly to a JSP rather to a servlet controller?
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The text exercise requires session bean for cart, well can you tell statements for JSP or/and Servlet, to empty it?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cart.empty()?

We don't know anything about your cart implementation--makes it much more difficult to tell you how it works.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean implement a method empty() {...} (where to can make/assign cart session bean, the
<jsp:useBean id="AddChoosePlant" scope="session" class="beans.OrderTotals" />
a new obj so it's properties get null values?), how assign?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you just asked. In the servlet you'd get the cart from session, then call empty() on it. That's it.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how "In the servlet you'd get the cart from session", can you tell statements?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused.

What is your level of understand of Java web application development? How (and occasionally if) we answer questions depends on the knowledge of the person we're answering: I assumed that since you were trying to write some sort of e-commerce application that you had the requisite experience to do so.

If you don't, I'd strongly recommend taking a step back and figuring out some basics before going much further--it will make moving forward *so* much easier.
 
Leonidas Savvides
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I covered SERVLETS/JSP two textbooks by course.com, and Java How to program 7/e by Deitel third, but since I forget, so if you tell a statement I will remember all(with little recap)...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!