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