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>