Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Designing a shopping cart

 
Shridhar Raghavan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hi,

So the first snippet is my html page which calls the servlet and submits the parameters. The second code is the servlet class whose duty is somewhat like a shopping cart. Maintain a list of records, and on the final submit button persist, the list. The problem i have right now is i do not show the list in the same page but in the servlet page. I would want to be able to show the list in the same page. Is this possible? I'm thinking AJAX, but is it possible in any other way and without the use of frameworks. It's a relatively small req?

 
rinku agarwal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt got what you want... so can you explain what exactly you need... So that anyone can help you...
 
Shridhar Raghavan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically i didnt like redirecting to a new page and losing the form elements. I needed the resulset to be displayed alongwith the filters in the same page. And i was wondering whether there was a cleaner way of achieving this than making an AJAX call to a servlet which writes to a response (response.getWriter.write("the response html tables would go here")) and we set the response in some div in this same html page? I dont like the idea of building html code in a servlet
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shridhar Raghavan wrote:And i was wondering whether there was a cleaner way of achieving this than making an AJAX call to a servlet which writes to a response (response.getWriter.write("the response html tables would go here")) and we set the response in some div in this same html page?


The servlet that handles the AJAX call need to build the "response" using response.getWriter.write - but can forward to an JSP page that builds the response html tables would go here

Usually there is no good reason to have HTML tags within java code & is never usually necessary (even for Ajax).

(When using AJAX, Think of as a normal servlet-jsp request response. Except that the response JSP page does not have a complete HTML page but is a fragment HTML page.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic