Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to highlight search keyword in text?

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to highlight search keyword in text?

    When I search by some Keyword

    I want display the result and Highlight me keyword for example:

    Keyword: Java

    "Java" display different from rest text

    any way: strong or change color ...etc

    my code use <c:forEach to display the result


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: How I can highlight keyword search?

    Hello Mohd,

    Have you already coded the search function?

    You just need to insert HTML tags before and after the keyword.

    <strong><font color="red">JAVA</font></strong>

    If you post your code here then ill see if I can help add it.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How I can highlight keyword search?

                <c:forEach var="book1" items="${bookList}">
                <tr>
                    <td>
                        <c:url var="listThreadsUrl" value="BookDetailsServlet">
       <c:param name="id" value="${book1.id}"/>
      </c:url>
     
      <a href='<c:out value="${listThreadsUrl}"/>'>
            ${book1.title}
      </a>
                </tr> 
                </c:forEach>

    the keyword forward from jsp page to servlet to perform query and finaly to other jsp page
    and here display the result

    my result is " book1.title "

    if you search for Java
    may will find "Java How to Program"

    Java here should be different

  4. #4
    Junior Member
    Join Date
    Dec 2008
    Location
    london
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How I can highlight keyword search?

    Quote Originally Posted by JavaPF View Post
    Hello Mohd,

    Have you already coded the search function?

    You just need to insert HTML tags before and after the keyword.

    <strong><font color="red">JAVA</font></strong>

    If you post your code here then ill see if I can help add it.
    in jsp it is possible but how in command prompt
    paruchuri

  5. #5
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How I can highlight keyword search?

    There is solution by using javascript

    I found this one
    Search Engine Keyword Highlight with Javascript | SYP

    but I didn't know how to use it in jsp

Similar Threads

  1. Implementation of search function for Patricia Trie
    By javaguy in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 21st, 2008, 02:54 PM