How to create google like instant search using JSP and servlets? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
开发者_如何学Python Improve this questionI am working on a basic instant search function that basically searches the database and displays the results instantly just like google instant. This here http://woorkup.com/2010/09/13/how-to-create-your-own-instant-search/ looks promising but I want to know if there is a way to implement this using JSP, java/servlets.
Java and servlets alone will not be sufficient, you will need JavaScript on the client side. Basically you attach a listener to the input field and send an AJAX request to a JSP that does the search and returns the results which you then only have to format and display in a drop-down box below the input field.
This is also a very good tutorial about instant search: http://www.w3schools.com/php/php_ajax_livesearch.asp
It uses Java Script and PHP. By reading / doing this tutorial you should get a idea how instant search works. So I hope this helps even if you want to use JSP.
You can do this using jQuery. The jQuery UI autocomplete is nice and easy to implement:
http://jqueryui.com/demos/autocomplete/
As previous posters have pointed out, you will have to use JavaScript to do this. The least painful way to use JavaScript here is to use JQuery UI
There is a fairly straightforward walkthrough here: http://blog.comperiosearch.com/2012/06/make-an-instant-search-application-using-json-ajax-and-jquery/
This is an oldie-but-goodie:
http://lab.abhinayrathore.com/autocomplete/
Combines Google,Bing,Yahoo,Wiki,Amazon, etc. all in 1 instant autocomplete. Allows you to easily add/remove websites.
精彩评论