Search code examples
javahtmllaunch

Is there a Java code which creates and launches a simple html page?


Is it possible to write a Java code which creates and launches an html page without saving any htm file?

I know there is a java code which automatically opens any given url in a default browser when it runs. Is it also possible for a java code to create a small html page, like this:

[title]TEST iFRAME DOCUMENT[/title]<br> 
[button type="button" onclick="myFunction()"]Click Me![/button]<br> 
[iframe id="demo" width="1140" height="541.25" src="https://www.stackoverflow.com/" frameborder="0"][/iframe]<br> 
[script] function myFunction() { document.getElementById("demo").src= "https://www.google.com/"; } [/script]

and then open it immediatelly in the default browser? If yes, what is the java code like?

P.S. Please consider [ = < and ] = > in the html document.


Solution

  • I have used Java as back-end for web development once. I used Tomcat to deploy my web page, Servlet to use HTTP methods such as POST and GET and JSP-files for the view. JSP-files are essentially compiled into Servlets. You can also use a Servlet to generate HTML-code using the out object. JSP is basically HTML-code where you can add Java by using <%%>, and Servlet is basically a Java class (Java code) where you can add HTML