aspose file tools*
The moose likes Servlets and the fly likes Designing a shopping cart Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Designing a shopping cart" Watch "Designing a shopping cart" New topic
Author

Designing a shopping cart

Shridhar Raghavan
Ranch Hand

Joined: May 27, 2010
Posts: 71



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

Joined: Feb 10, 2010
Posts: 6
I didnt got what you want... so can you explain what exactly you need... So that anyone can help you...
Shridhar Raghavan
Ranch Hand

Joined: May 27, 2010
Posts: 71
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

Joined: Feb 08, 2009
Posts: 605

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.)


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Designing a shopping cart