How to create a servlet to return a database request to a specific div
I need to create a very simple application:
- I need a form that submits data to a servlet
- The servlet then queries the database for a list of reports based on the criteria specified by the form
- The returned document list should appear in a div in the .jsp page
I'm not sure about the latter (number 3). I know how to call doPost or some other method using jQuery (but not when the button is fired) using just a timer, but I'm sure it looks like it. But I want to keep it as simple as possible and avoid jQuery if possible.
If I call the servlet and return data without using jQuery, how can I specify the location (i.e. which div) I want it to be returned.
a source to share
If you are showing the content of your Ajax request, it depends on the client-side Javascript. The servlet will just create the data (either as HTML or JSON or XML, whichever you want on the client).
If you don't want to use jQuery (or prototype.js or something similar), you need to code the logic to disable the Ajax request and to parse the result (including displaying it).
I would say stick with jQuery. This will keep it "as simple as possible". If you are unsure of how to start a new query when a button is clicked, check out this tutorial .
a source to share