How can I get content of a jsp page, after servlet made a forward. At them moment I'm trying the following:
request.getRequestDispatcher(DESTINATION_PAGE).forward(request, response);
URL teamsURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + DESTINATION_PAGE);
URLConnection teamsCon = teamsURL.openConnection();
String fileName = request.getServletContext().getRealPath("/") + System.currentTimeMillis() + ".html";
System.out.println(fileName);
try (BufferedReader in = new BufferedReader(new InputStreamReader(teamsCon.getInputStream()));
PrintWriter out = new PrintWriter(fileName)) {
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
out.println(inputLine);
}
}
I get the html with empty divs. But, I want the same page I see in browser.
Sorry for messy post, ask for what info you need, I'll update my post accordingly.