0

hey guys,
i'm new to java servlets..i have been making a website using java servlets on stock market and stuff...now what my query is that i want to retrieve data from database(ms-access) and display it on my html page....

i don't have much knowledge about html so i took a css template from internet and started working on it...what i have been trying to do is that i included all of the html tags in .java file(servlet) so that html page could be dynamic...

but this thing is very hectic...its giving me whole lot of errors..i mean i tried to include whole of the template in servlet programming...but lot of errors...

So can anybody please suggest me another method(leaving jsp) to display my data from database on html page using servlets or help me with my coding...i have attached the code with my post!!!!

Attachments
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class serv2 extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{

PrintWriter pw=res.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("<title>Untitled Document</title>");
pw.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
pw.println("<link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\">");
pw.println("<style type=\"text/css\">");
pw.println("<!--
.style1 {
	font-size: 11px;
	font-weight: bold;
}
-->");
pw.println("</style>");
pw.println("<script language=\"JavaScript\" type=\"text/JavaScript\">");
pw.println("<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->");
pw.println("</script>");
pw.println("</head>");
pw.println("<body onLoad=\"MM_preloadImages('images/fing_btn_h.gif')\">");
pw.println("<table width=\"100%\" height=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
pw.println("<tr>");
pw.println("<td height=\"10\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td width=\"207\" valign=\"middle\" background=\"images/hd_bg.gif\" class=\"bgx\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td width=\"38%\" align=\"right\"><img src=\"images/logo.jpg\" width=\"47\" height=\"45\"></td>");
pw.println("<td width=\"62%\" class=\"company_name\">The Stocks </td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("<td width=\"359\"><img src=\"images/hd_pic.jpg\" width=\"359\" height=\"96\"></td>");
pw.println("<td background=\"images/hd_bg.gif\" class=\"bgx\">&nbsp;</td>);
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td height=\"100%\" valign=\"top\"><table width=\"100%\" height=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
pw.println("<tr>");
pw.println("<td background=\"images/menu_bg.gif\" class=\"bgx\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td align=\"center\" class=\"menu\"><a href=\"index.htm\" class=\"menu_lnk\">Home</a></td>");
pw.println("<td width=\"7\"><img src=\"images/menu_sep.gif\" width=\"7\" height=\"28\"></td>");
pw.println("<td align=\"center\" class=\"menu\"><a href=\"portfolio.htm\" class=\"menu_lnk\">PORTFOLIO</a></td>");
pw.println("<td width=\"7\"><img src=\"images/menu_sep.gif\" width=\"7\" height=\"28\"></td>");
pw.println("<td align=\"center\" class=\"menu\"><a href=\"#\" class=\"menu_lnk\">Testimonials</a></td>");
pw.println("<td width=\"7\"><img src=\"images/menu_sep.gif\" width=\"7\" height=\"28\"></td>");
pw.println("<td align=\"center\" class=\"menu\"><a href=\"conversations.htm\" class=\"menu_lnk\">CONVERSATIONS</a></td>");
pw.println("<td width=\"7\"><img src=\"images/menu_sep.gif\" width=\"7\" height=\"28\"></td>");
pw.println("<td align=\"center\" class=\"menu\"><a href=\"Contact.html\" class=\"menu_lnk\">Contact Us..</a></td>");
pw.println("<td width=\"7\"><img src=\"images/menu_sep.gif\" width=\"7\" height=\"28\"></td>");
pw.println("<td width=\"100%\">&nbsp;</td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td height=\"100%\"><table width=\"100%\" height=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
pw.println("<tr>");
pw.println("<td width=\"207\" valign=\"top\" background=\"images/sub_left_bg.gif\" class=\"bgy\"><div style=\"position:absolute;left:-3072px;top:0\"><ul><li><a href=\"http://anvision.com/\"><strong>Offshore outsourcing Russia : software outsourcing, IT outsourcing</strong></a></li><li><a href="http://anvisionwebtemplates.com/"><strong>Free web templates</strong></a><ul><li><a href="http://anvisionwebtemplates.com/free-web-templates/free-business-web-templates.html"><strong>Free business web templates</strong></a></li></ul></li><li><a href="http://anvisionwebdesign.com/"><strong>Web design</strong> company</a></li><li><a href="http://anvisionwebhosting.com/"><strong>Web hosting</strong> company</a></li><li><a href="http://just-dating.net/">Online <strong>dating service</strong></a></li><li><a href="http://realestatehawk.net/"><strong>Real estate listings</strong></a></li><li><a href="http://softwareguys.net/"><strong>PHP software</strong> scripts</a></li><li><a href="http://jobsearch4.com/">Online <strong>job search</strong></a></li><li><a href=\"http://web-page-design.info/\"><strong>Web designers</strong> directory</a></li><li><a href=\"http://advertisingfinders.net/\"><strong>Advertising firms</strong> directory</a></li><li><a href=\"http://attorneysfinders.net/\"><strong>Attorneys</strong> directory</a></li><li><a href=\"http://autodealerfinders.net/\"><strong>Auto dealers</strong> directory</a></li><li><a href=\"http://dentistfinders.net/\"><strong>Dentists</strong> directory</a></li><li><a href=\"http://inspectionfinders.net/\"><strong>Home inspectors</strong> directory</a></li><li><a href=\"http://photographerfinders.net/\"><strong>Photographers</strong> directory</a></li><li><a href=\"http://realtorfinders.net/\"><strong>Realtors</strong> directory</a></li><li><a href=\"http://seofinders.net/\"><strong>Seo firms</strong> directory</a></li><li><a href=\"http://webdesignfinders.net/\"><strong>Web design</strong> directory</a></li><li><a href=\"http://webhostingfinders.net/"><strong>Web hosters directory</strong></a></li></ul></div><table width=\"100%\"  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"images/sub_l_panel.gif\" class=\"norepeat\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"14\"></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"about us.htm\" class=\"SUB_lnk\">About us</a> </td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"worldmarket.htm\" class=\"SUB_lnk\">world Markets &amp; Solutions</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"focusnews.htm\" class=\"SUB_lnk\">Focus News</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"expertsview.htm\" class=\"SUB_lnk\">Expert's views</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width="1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"info.htm\" class=\"SUB_lnk\">Share Information</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"forecast.htm\" class=\"SUB_lnk\">Market Forecast</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"support.htm\" class=\"SUB_lnk\">Services &amp; Support</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</tr>");
pw.println("<tr>");
pw.println("<td><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
pw.println("<tr>");
pw.println("<td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td>");
pw.println("<td align=\"right\" class=\"submenu\"><a href=\"comodities.htm\" class=\"SUB_lnk\">Comodities</a></td>");
pw.println("</tr>");
pw.println("</table></td>");
pw.println("</t
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by javaAddict
0

your class must have the same name as the name file.
ther is lot of mistackes in you code: open braket not closed, open double cote not closed.
The css grammer and language is not allowed to be used directty in a java file.
The sum: you have to learne about the java language grammar and syntax and the servelet technology.

0

So can anybody please suggest me another method(leaving jsp) to display my data from database on html page

If you want to display data to html page then you use jsp.
Jsp is actually constructed using html tags. So if you don't know html how can you create a web page? If you don't know java how can you display the data?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.