hi everyone,

I have written a servlet program,which creates a resultset,
and fwd to a jsp page which shall display the records.
The problem is that iam not able to compile the java program.
The source and error message is below  ..
is there some other jar files that have to be included in class path...
any help would be greatly appreciated.
iam using jdk1.2.

rds,
naveen

*********************
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class Resultsets extends HttpServlet {

Connection PubCon;
ResultSet PubRset=null;
Statement Pubstmt;
public String PubSql="";
public String redata;
ResultSetMetaData PubRsetMdata;
public String strhtml;
public String surveyName;

 public void doPost (HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException
    {

 try
    {
  DbConnect();
    }
 catch(Exception Exc)
      {
  strhtml += "Not able to connect to DB";
      }

 req.setAttribute("rs",PubRset);
 RequestDispatcher rd =
getServletContext().getRequestDispatcher("/jsp/myapp/results.jsp");
 rd.forward(req,res);


 }

public void DbConnect()
{

 try{
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Connection c = DriverManager.getConnection("jdbc:odbc:naveen","dba","sql");
 Statement st=c.createStatement();
 PubRset=st.executeQuery("Select Name,ID,Place,Dgn from employee");
    }
 catch(Exception ex)
 {
  strhtml="wrong sql execution";
 }
}

}

***********************
Error:

C:\JSDK2.0\examples\Resultsets.java:32: Method
setAttribute(java.lang.String, java.sql.ResultSet) not found in interface
javax.servlet.http.HttpServletRequest.
 req.setAttribute("rs",PubRset);
C:\JSDK2.0\examples\Resultsets.java:33: Method
getRequestDispatcher(java.lang.String) not found in interface
javax.servlet.ServletContext.
 RequestDispatcher rd =
getServletContext().getRequestDispatcher("/jsp/myapp/results.jsp");
                                                                ^

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to