简体   繁体   English

将字符串从servlet传输到jsp页面,而无需刷新

[英]Transfer string from servlet to jsp page without refreshing

I have a text area (*id="txtResults"*) in my jsp page. 我的jsp页面中有一个文本区域(*id="txtResults"*) The servlet program retrieves data from an ontology and stores it in a string(*name=solution*) . Servlet程序从本体检索数据并将其存储在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. 我只想要一种简单的方法来将此字符串传输到jsp页面并在文本区域中打印它,而无需刷新整个页面。 Help would be appreciated! 帮助将不胜感激!

From your tag ajax lies the answer , 从您的标签ajax中可以找到答案,

i guess you are not aware where to start with , here is the link jQueryAjax 我猜你不知道从哪里开始,这是jQueryAjax的链接

And also nice startup examples How to use Servlets and Ajax? 还有不错的启动示例如何使用Servlet和Ajax? and here 在这里

Hope this helps !! 希望这可以帮助 !!

Use jQuery Ajax ie Asynchronous JavaScript and XML 使用jQuery Ajax即异步JavaScript和XML

AJAX is about loading data in the background and display it on the webpage, without reloading the whole page AJAX是关于在后台加载数据并将其显示在网页上,而无需重新加载整个页面

Go through Ajax documentation Documentation 浏览Ajax文档文档

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 ). 正如Sam Krish所建议的那样,Ajax是最好的方法(AJAX有很多API。Jquery是一种。如果您准备在自己的XMLHttpRequest上编写一个,则是ypur键。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). 如果您使用的是旧版代码,则可以使用IFrame来完成相同操作(请不要使用这种方式)。

When comes to passing data to the Servlet .. its as simple as any GET or POST. 当涉及到将数据传递到Servlet ..时,就像任何GET或POST一样简单。 you can embed the data as part of the URL and call the request.getParameter in the servlet to retrieve the data. 您可以将数据嵌入为URL的一部分,并在servlet中调用request.getParameter来检索数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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