How to append some text in div with id="sw" and befor "<-- adding some thing here />" and write in response output in JSP ?
"index_012.html content is:
<html><head></head><body>
<div id="maincontent" class="maincontent">
<section id="mainthecontent">
<div id="swRight"></div>
<div id="sw" >
<!--adding some thing here-->
</div>
<div class="clear"></div>
</section>
<div class="clear"></div>
</div>
</body></html>
my jsp code is :
FileReader fr = new FileReader("index_012.html");
BufferedReader br = new BufferedReader(fr);
StringBulder addingContent= "<div>Main Content</div>";
StringBulder result="";
String line = null;
// finding place to adding StringBulder
int contentPlace = -1;
while((line=br.readLine()) != null && contentPlace==-1){
int swIndex = line.indexOf("\"sw\"");
contentPlace = line.indexOf(">",swIndex);
}
if(contentPlace>-1){//contentPlace is index of where i must append "addingContent"
--------i need help here ----------
result = br.append(addingContent , contentPlace);
--------i need help here ----------
}
and then this jsp tag
<%= result %>
I don't need any change in index_012.html or any other file
write in response output
in Other word how to read file as StringBulder --> replace somthing --> write to response ??