0

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??

Thanks
oggiemc

import java.io.*;
import java.lang.*;
import java.sql.*;
	
	public void JobSearch(String sector, PrintWriter out) 			
	           {
		
              String thisSector = sector;
                          
              try
      		   { 
            	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.");
      	       }   
          
            
        }

}
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by oggiemc
-1

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

Edited by tyson.crouch: n/a

0

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

0

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

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.