import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import sun.jdbc.rowset.*; public class FetchEmployee extends HttpServlet { public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { try { Connection con; Statement smt; ResultSet rs; String fsal="100"; String tsal = "800"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:mydsn","",""); smt = con.createStatement(); String sql = "select * from employee where sal between "+fsal+" and "+tsal; System.out.println(sql); rs = smt.executeQuery(sql); CachedRowSet crs = new CachedRowSet(); crs.populate(rs); HttpSession s = req.getSession(true); s.setAttribute("mycrs",crs); res.sendRedirect("http://localhost:8080/servlet/ShowEmp"); } catch(Exception e) { System.out.println(e); } } }