views:

317

answers:

1

I need to create a very simple application:

  1. I need to have a form that submits data to a servlet
  2. The servlet then queries a database to retrieve a list of reports based on the criteria given by the form
  3. The returned list of documents has to displayed in a div on a .jsp page

I am not sure about the last one (number 3). I know how to call the doPost or some other method using jQuery (but not when triggered by a button), only using a timer, but I am sure it's a similar thing. But I want to keep it as simple as possible and avoid jQuery if possible.

If I call the servlet and return the data without using jQuery, how can I specify the location (i.e. which div) I want it to be returned in.

+1  A: 

Where you display the contents of your Ajax request is up to the client-side Javascript. The servlet will just create the data (either as HTML, or as JSON or XML, depending on what you need on the client).

If you do not want to use jQuery (or prototype.js, or something similar), you have to code the logic for firing off the Ajax request, and for parsing the result (including how to display it) yourself.

I'd say, stick with jQuery. That will keep it "as simple as possible". If you are not sure how to start a new request when a button is clicked, check out this tutorial.

Thilo