This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Search fuction in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Search fuction in JSP " Watch "Search fuction in JSP " New topic
Author

Search fuction in JSP

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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")

Any help???
Thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41129
    
  45
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.


Ping & DNS - my free Android networking tools app
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41129
    
  45
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Search fuction in JSP
 
Similar Threads
Search Page - question
Browser Refresh
I want two buttons on a page, one for "search refine", one for "submit", how to do ?
Hi Experts, Big problem
Question about simpleformcontroller