Dear Friends.,
Am new to the java world.. I am creating a application where i have to generate a html page from a Dynamic jsp page..
I have tried my best and i was able to create a static html page from a JSP..
But how to fill the data into the HTML is the problem for me,.. Please help me
find the code to generate the HTML file from JSP..
function crehtml()
{
alert("jaiprakash");
<%
String path = "/home/administrator/Raj/jai/output.html";
String path3 = "fdfdsfjdjsff";
File file = new File(path);
Writer wr = new BufferedWriter(new FileWriter(file));
wr.write("<html><head><title>jai</title>");
wr.write("<style>");
// Write the contents of the style sheet into the page
String styleSheetPath ="/home/administrator/Raj/jai/style.css";
// Create input stream object.
FileInputStream fis = new FileInputStream( styleSheetPath );
// Set variable for looping through bytes.
int c;
while( (c = fis.read() ) != -1) {
wr.write(c); // Loop to read and write bytes.
}
fis.close(); // Close output and input resources.
// Done writing out style sheet
wr.write( "</style>" );
wr.write("<SCRIPT>");
wr.write("function dddd(){ ");
wr.write("var name =\"jpai\";");
wr.write("var age = \"jpai\";");
wr.write("var ade = \"jpai\";");
wr.write("var check = \"jpai\";");
wr.write("document.getElementById(\"name\").innerHTML = \"<p>\"+name+\"<br/>\"+age+\"<br/>\"+ade+\"<br/>\"+check+\"</p>\";");
wr.write("}</SCRIPT>");
wr.write("</head>");
wr.write("<body onLoad=dddd()>");
wr.write("<table>");
wr.write("<tr><td>");
wr.write("<table width=\"900px\" cellpadding=\"2\" cellspacing=\"0\" class=\"table\">");
wr.write("<tbody ><tr height=\"100px\" class=\"tr1\">");
wr.write("<td width=\"125px\">");
wr.write("<p><b>Order ID:<br/>Order Date:<br/>Order Type:<br/>Parent ID:</b></p></td>");
wr.write("<td id=\"orderid\" width=\"125px\"> </td>");
wr.write("<td width=\"150px\"><p><b>Customer:<br/>Sales Exec:<br/>CO Reference:<br/>Partner ID:</b></p></td>");
wr.write("<td width=\"150px\" id=\"customername\"> </td>");
wr.write("<td width=\"350px\" class=\"tr2\"><div id=\"billingaddress\"> </div></td></tr></tbody>");
wr.write("</table>");
wr.write("</td></tr><tr><td>");
wr.write("<table width=\"900px\" class=\"table\" align=\"left\" id=\"productTable\" cellpadding=\"3\">");
wr.write("<thead>");
wr.write("<th class=\"th\" width=\"8%\">Sl.No.</th>");
wr.write("<th class=\"th\" width=\"12%\">jai Id</th>");
wr.write("<th class=\"th\" width=\"13%\">Description</th>");
wr.write("<th class=\"th\" width=\"10%\">jai Name</th>");
wr.write("<th class=\"th\" width=\"15%\">Features</th>");
wr.write("<th class=\"th\" width=\"10%\">Period</th>");
wr.write("<th class=\"th\" width=\"8%\">Qty</th>");
wr.write(" <th class=\"th\" width=\"8%\">Time Units</th>");
wr.write("<th class=\"th\" width=\"8%\">Rate</th>");
wr.write("<th class=\"th\" width=\"8%\">Total</th>");
wr.write("</thead>");
wr.write("<tfoot>");
wr.write("<th width=\"8%\"> </th>");
wr.write("<th width=\"12%\"> </th>");
wr.write("<th width=\"13%\"> </th>");
wr.write("<th width=\"10%\"> </th>");
wr.write("<th width=\"15%\"> </th>");
wr.write("<th width=\"10%\"> </th>");
wr.write("<th width=\"8%\"> </th>");
wr.write("<th width=\"8%\"> </th>");
wr.write("<th width=\"8%\"><p>Total:<br/>Discount:<br/><br/>NetValue:</p></th>");
wr.write("<th width=\"8%\">");
wr.write("<p><label id=\"totvalue\" name=\"totvalue\"> </label><br/>");
wr.write("<label id=\"discount\" name=\"discount\"> </label><br/>");
wr.write("_______");
wr.write("<label id=\"orderval\" name=\"orderval\"> </label></p>");
wr.write("</th></tfoot></table></td></tr><tr><td>");
wr.write("<table align=\"left\" cellpadding=\"3\" cellspacing=\"2\" class=\"table\">");
wr.write("<thead><th class=\"th\" align=\"left\">");
wr.write("<font class=\"fontheader1\" id=\"actionheader\">Action Details - 0</font>");
wr.write("</th></thead><tbody><tr><td>");
wr.write("<table id=\"orderactions\"><tbody>");
wr.write("</tbody></table></td></tr></tbody></table></td></tr>");
wr.write("</table>");
wr.write("</body>");
wr.write("</html>");
wr.flush();
wr.close();
%>
}
css file
/*body {background-color: yellow} h1 {font-size: 36pt} h2 {color: blue} p {margin-left: 50px}*/
body {
background: #FFFFFF;
margin: 0;
font-family: 12px, Verdana, Helvetica, Arial, sans-serif;
color: #292929;
margin: 0;
}
p {
font-family: Verdana, Helvetica, Arial;
font-size: 12px;
color: #292929;
font-weight: normal;
line-height: 18px;
text-align: justify;
}
.submit
{
BORDER-RIGHT: lightgrey thin outset;
BORDER-TOP: lightgrey thin outset;
FONT-SIZE: 8pt;
BORDER-LEFT: lightgrey thin outset;
COLOR: #000000;
BORDER-BOTTOM: lightgrey thin outset;
FONT-FAMILY: Arial, Helvetica, sans-serif;
LETTER-SPACING: 1px;
BACKGROUND: #DEE5EB;
}
TEXTAREA
{
FONT-SIZE: 11px;
FONT-FAMILY: Tahoma, Arial;
color: #292929;
border: 1px solid #7F9DB9;
}
.heading {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
font-weight: bold;
color: #FFFFFF;
}
.text {
font-family: Tahoma, Arial;
font-size: 11px;
color: #333333;
font-weight: normal;
line-height: 18px;
}
select {
FONT-FAMILY: Tahoma, Arial;
font-size: 11px;
line-height: 18px;
font-weight: normal;
color: #292929;
text-decoration: none;
border: 1px solid #7F9DB9;
}
.select {
FONT-FAMILY: Tahoma, Arial;
font-size: 11px;
line-height: 18px;
font-weight: normal;
color: #292929;
text-decoration: none;
border: 1px solid #7F9DB9;
}
.para {
font-family: Tahoma, Arial;
font-size: 11px;
color: #60656C;
line-height: 18px;
text-align: justify;
font-weight: normal;
}
.bg_body_bottom {
background-image: url(images/body_bottom.jpg);
background-repeat: no-repeat;
background-position: center bottom;
}
input {
FONT-SIZE: 11px;
FONT-FAMILY: Tahoma, Arial;
color: #292929;
border: 1px solid #7F9DB9;
}
.colorbox {
background-color: #FFFFCC;
text-align: justify;
border: 1px solid #CDD6DD;
font-family: Tahoma, Verdana, Arial;
font-size: 11px;
color: #333333;
line-height: 16px;
}
strong {
font-family: Tahoma, Verdana, Arial;
font-size: 11px;
font-weight: bold;
color: #000000;
}
table
{
border-collapse: separate;
empty-cells: show;
}
fieldset{
border: 1px solid #7F9DB9;
}
#fieldset1{
border: 1px solid #7F9DB9;
width: 390px;
}
#fieldset2{
border: 1px solid #7F9DB9;
width: 390px;
}
.rightcoldiv h2 {
margin: 0 0 5;
font-size: 16px;
padding: 3px 0px 3px 10px;
color: white;
padding: 3px 0px 3px 10px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #e27901;
background-color: #1869BD;
background-repeat: repeat;
}
.bluetext {
color: #5584B0;
font: menu;
font-size: 13px;
}
.blueboldtext {
color: #5584B0;
font: menu;
font-size: 13px;
font-weight: bold;
}
.fontstyle1{
font-family: Verdana, Helvetica, Arial;
font-size: 9px;
font-color: #000000;
font-weight: normal;
line-height: 11px;
text-align: justify;
}
.fontheader1{
font-family: Verdana, Helvetica, Arial;
font-size: 11px;
font-color: #000000;
font-weight: bold;
line-height: 12px;
text-align: justify;
}
/*----siva-------------*/
.table
{
border-collapse: separate;
empty-cells: show;
/*border: 2px outset #7F9DB9 ;*/
}
.tblCardView{
border-collapse: separate;
empty-cells: show;
/*border: 2px outset #7F9DB9 ;*/
}
.td{
FONT-SIZE: 14px;
FONT-FAMILY: Tahoma, Arial;
color: #000000;
border-color: #ECF9FF;
border-style: ridge;
}
.td1{
background-color: #DAE4F0;
border-top: dashed thin black;
border-bottom: dashed thin black;
border-left: dashed thin black;
border-right: dashed thin black;
}
.tr1{
background-color: #DAE4F0;
border-top: solid thin black;
border-bottom: solid thin black;
border-left: solid thin black;
border-right: solid thin black;
}
.tr2{
background-color: #C4D3E6;
border-top: solid thin black;
border-bottom: solid thin black;
border-left: solid thin black;
border-right: solid thin black;
}
.th{
background-color: #B0C4DD;
FONT-SIZE: 11px;
FONT-FAMILY: Tahoma, Arial;
color: #000000;
border-color: #ECF9FF;
/*border-style: ridge;*/
}
.outerborder{
border-top: solid thin;
border-bottom: solid thin;
border-left: solid thin;
border-right: solid thin;
}
.tdLabel{
text-align: left;
width: 40%
}
.label{
font-family: Arial,Helvetica,sans-serif;
font-size: 12px;
}
.boxheading {
padding: 5px 0;
text-indent: 10px;
background: #F7F7F7;
/*display: block;*/
border-bottom: 1px solid #DDD;
color: #4A69A5;
text-decoration: none;
}
.columnHeading{
padding: 5px 0;
text-indent: 10px;
background: #F7F7F7;
/*display: block;*/
border-bottom: 1px solid #DDD;
color: #4A69A5;
text-decoration: none;
font-weight: strong;
}
.urPcBodyPln{background-color:#FFF;font-family:Arial,Helvetica,sans-serif;font-size:medium}
now i have to fill some value to this html page from the jsp page.. means i have to get the value from the jsp page and fill it here.. please help