Hi everyone,

i want to output the results of the select statement in the code below, to a html table as opposed to just a list of out.println statemants..Can someone tell me how to go about doing this please??


import java.io.*;
import java.lang.*;
import java.sql.*;
	public void JobSearch(String sector, PrintWriter out) 			
              String thisSector = sector;
            	out.println("JOBID --- SECTOR --- LOCATION--- SALARY--- EMAIL--- DESCRIPTION--- COMPANY <br>");  
      		stmt = con.createStatement();
      		rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'");
      		while (rs.next())
             out.println( rs.getString("JOBID") + "---" + rs.getString("SECTOR") + "--- " +
                rs.getString("LOCATION") + "--- " + rs.getString("SALARY") + "--- " + rs.getString("EMAIL")
                + "--- "+rs.getString("DESCRIPTION") + "---" + rs.getString("COMPANY") +"<br>"); 
              catch (Exception e) {
      	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");


Your code looks to be fine, though a little messy.

In order to do this, you need to use JSP, this way you can output to a HTML page with the table that you desire.

The link provided by peter_budo will take you through a tutorial for using java with JSP

thanks guys, will have a llok at this..

Hi guys, that example has gone a liitle bit over my head..Do yous advise using a JSP to output my data to a HTML table?? If possible i would rather just use the servlet, but a jsp is perhaps better for outputting larger amounts of data??
If i have to use a jsp, how do i tansfer the data retrieved from my serlvet, to the jsp?
Or do i not use a servlet at all??
Any input would be much appreciated here thanks

also, is it possible to INSERT objects (which contain all the parameters) into the DB instead of INSERTING individual strings??