0

How do you populate text fields using AJAX from JSP scriptlet with data obtained from Oracle 10g database? How do you get a handle on those input elements of type text from a jsp? Using javascript? but how do you use the values in the scriptlet?

Thanks

Namratha
  • 16,630
  • 27
  • 90
  • 125
  • Duplicate of http://stackoverflow.com/questions/2203269/loading-alternative-content-via-tabs-and-jquery-and-jsp, http://stackoverflow.com/questions/2758873/need-json-results-in-a-table-format, http://stackoverflow.com/questions/3614703/calling-a-servlet-from-a-jsp-page-using-jquery-ajax, http://stackoverflow.com/questions/3028490/calling-a-java-servlet-from-javascript, etc..etc.. Using scriptlets is by the way the wrong approach. It should be handled by a servlet. Java code doesn't belong in JSP files. – BalusC Nov 03 '10 at 18:31
  • Sorry about the repetition. Thank you. – Namratha Jan 25 '11 at 06:25

2 Answers2

1

Not sure if I understand what you mean. You have JSP page that reads data from DB and some other page with text inputs. You want to populate these inputs with data from JSP using AJAX call, right ? So just write javascript that will hit JSP page and get a response in JSON format with data from DB and then populate the input fields.

maestr0
  • 5,318
  • 3
  • 28
  • 27
1

If I am understanding your question right : Why not use a javascript templating engine and just populate and render the template with the json response? If you haven't used templates like this, I would probably investigate. There are quite a few options out there, Mustache is a decent one : http://mustache.github.com/. http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/

Mike Croteau
  • 1,062
  • 2
  • 16
  • 43