1

How do I save a dynamic JSP page to a static HTML page using Java code?

I want to save JSP output to an HTML page and save it on the local machine.

2 Answers 2

2

How do I save a dynamic JSP page to a static HTML page using Java code?

Once the client receives the JSP page the server has already performed all the "dynamic stuff". So, just download the web page into for instance a String using, say, the URL class, and write this String out to a file. (You won't get the dynamic parts anyway.)

Related question (possibly even duplicates):

Sign up to request clarification or add additional context in comments.

Comments

1

Write a Java client application that does something like this...

URL yahoo = new URL(THE URL OF YOUR JSP PAGE);
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

String inputLine;
String html;

while ((inputLine = in.readLine()) != null) 
   html += inputLine + "\n";
in.close();

// DO SOMETHING WITH THE HTML STRING

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.