Adding result from jsp page to html using servlet
Hello All,
Im developing an application that uses servlet. In that I want to add the result of jsp page into the html page that im showing through outputstreeam.
the html is shown in following way
path = getServletContext().getRealPath(folder)
+ "/LoginPage.html";
BufferedReader br = new BufferedReader(new FileReader(path));
StringBuffer buffer = new StringBuffer();
String line = br.readLine();
boolean skip = false;
while (line != null) {
if (line.indexOf("name=\"UID\" value=") != -1) {
//uiRead = true;
String tempLine = line.substring(0, line
.indexOf("name=\"UID\" value=") + 18);
line = tempLine
+ UniquId
+ line.substring(line.indexOf("name=\"UID\" value=") + 18, line.length());
buffer.append(line);
}else if(!skip){
skip = true;
int index = -1;
index = line.indexOf("your")+5;
if (id != null) {
line = line.concat(id);
}
buffer.append(line);
}else{
buffer.append(line);
}
line = br.readLine();
}
br.close();
response.setContentType("Text/HTML");
OutputStream os = response.getOutputStream();
os.write(buffer.toString().getBytes());
//JSP response
os.flush();
os.close();
after adding all lines then I want to add the result that I get from JSP.
To get response Im using RequestDispatcher and use include(). But I am not getting how to retrieve the response from include and add into above code.
Please if any body knows let me know too.
Any code snippet will be greatfull.
Thanks