I have a text area(*id="txtResults"*)
in my jsp page. The servlet program retrieves data from an ontology and stores it in a string(*name=solution*)
. I just want a simple way to transfer this string to the jsp page and print it in the text area without refreshing the whole page.
Help would be appreciated!
-
How do you retrieve string in servlet? – niiraj874u Apr 25 '14 at 05:31
3 Answers
From your tag ajax
lies the answer ,
i guess you are not aware where to start with , here is the link jQueryAjax
And also nice startup examples How to use Servlets and Ajax? and here
Hope this helps !!
Use jQuery Ajax
i.e. Asynchronous JavaScript and XML
AJAX is about loading data in the background and display it on the webpage, without reloading the whole page
Go through Ajax documentation Documentation
here you will get some examples

- 6,659
- 8
- 41
- 57
As suggested by Sam Krish, Ajax is the best way to do it (LOTs of APIs are there for AJAX.. Jquery is one. If you ready to write one on your own XMLHttpRequest is ypur key. http://www.w3schools.com/xml/xml_http.asp ).
if you working in some legacy code.. then the same can be accomplished using IFrames (Please do not use this way).
When comes to passing data to the Servlet .. its as simple as any GET or POST. you can embed the data as part of the URL and call the request.getParameter in the servlet to retrieve the data.

- 69
- 2