Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:26:49+00:00 2026-06-17T22:26:49+00:00

I have a JSP where in a text area i am reading the String

  • 0

I have a JSP where in a text area i am reading the String array of a whole sentence and printing it line by line. No i want to highlight some patter in the line in BOLD and red color font. e.g. if the line which is being read contains pattern “error” (it can be a single word or a part of a word like “initializationerror” or “”), i t will be highlighted in BOLD and red color. The rest of the line will be print as it is.

Below is the code snippet:

<table border="2">
<% 
    if(session.getAttribute("Result") != null)
    {
        String Result = (String) session.getAttribute("Result");
        if(Result.length() != 0)
        {
            String[] split_EOL = Result.split("\n");
%>
            <tr align="center"> 
                <td>
                    // Text area start here 
                    <textarea rows="50" cols="100" readonly="yes">   
<%
                        for(int i = 0; i < split_EOL.length; i++)
                        {
                            out.println(split_EOL[i]);
                            out.println(" ");
                        }
%>
                    </textarea>
                 </td>
             </tr>
<%
         }
    }
%>
</table>

Please help

I tried the following:

<textarea rows="50" cols="100" readonly="yes"> 
<% 
     for(int i=0;i<split_EOL.length ; i++){ 
     out.println(split_EOL[i].replaceAll("\\b\\w*"+Pattern+"\\w*\\b", "<b>$0</b>"));   
     out.println(" "); 

                                          }
%> 
</textarea> 

here Pattern = ERROR….. but it displays like this

95323:[<b>ERROR</b>] Logger not set 

even i trued to display some word in bold in out.println but it didnt render the bold tags:

 out.println("<b>"+Pattern+"</b>");%>

displays only

<b>ERROR</b>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:26:51+00:00Added an answer on June 17, 2026 at 10:26 pm

    You can replace the pattern \b\w*error\w*\b with a <span class="error-string">$0</span>

    out.println(split_EOL[i].replaceAll("\\b\\w*error\\w*\\b", "<span class=\"error-string\">$0</span>"));
    

    and define in CSS

    error-string {
        color: red;
        font-weight: bold;
    }
    

    If you need a case insensitive search, you can prefix your pattern with (?i), see Pattern – Special constructs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area and enter some content in this text-area I want
I have a JSP with some monetary amounts in £s. I want people viewing
I have a combo of javascript and my jsp that is adding some text
I have a HTML text area in a JSP page. When I continuously press
I have a text area with some text. I also have an onsubmit event
I have an existing JSP page that displays some static text. I'd like to
In my JSP,I have a Java array menuNames ,I want to assign a value
I have a jsp form validate.jsp which contains 2 text fields where user enters
I have an HTML table in my jsp page. This conains text fields and
I have a jsp that contains a table with some information from db. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.