简体   繁体   中英

Transfer string from servlet to jsp page without refreshing

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!

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 ie 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM