Hello, i have to build a search fuction in my website. In main page(JSP) i have a text field and a submit button. When button clicked, user should transfer to goods list (JSP) where all my goods retrieved from store(XML). I have stuck at the point where only goods with name similar to the keyword should be displyed. (ex. If user insert "to" in main page, goods list page should present "Tomatoes" and "Toaster" or if insert "apples" only "Apples")
Where is the data stored? If it's in a DB, then SQL covers this case (read up on the LIKE operator and the LOWERCASE/UPPERCASE functions). If the data is in files, then using a library like Lucene may help.
As i said, i have a xml file and stored all my datas there. Sorry but im a lil bit fresh, what is Lucene library
Joined: Mar 22, 2005
I see, I misinterpreted the mention of XML. You can use one of the XML APIs (maybe SAX or DOM; and possibly XPath) to iterate through all goods and perform some appropriate string operations to do the comparison. Something like nameOfGood.toLowerCase().indexOf(userInput.toLowerCase()) != -1.
As to Lucene, a web search will find its home page (which has extensive documentation) quickly; it's not like that's a common word.