set action of the jsp form to a servlet name eg ....action ="myservlet"
In the post/get method of myservlet,
get the data from the jsp using
the method getParameter("paramName").
Connect to the bean and set these values (Can use jndi for cmp)
the bean connects to the dbase
if no exceptions are thrown, forwad to success jsp
Use req.getRequestDispatcher("/successJSP").include(req, resp);
If you need to use the bean in successJSP set it as an attribute for req
and access it in the jsp using getAttribute("attrName")
well first you need to configure a driver to conect with the database, i use the jdbc-odbc so i need first to configure an ODBC of the database, i use only jsp not beens:
first i get the username and the password from a form and save the data in session in orde to remmember for another operations
<%
String identificador = request.getParameter("id");
String clave = request.getParameter("clve");
session.setAttribute("nom",identificador);
session.setAttribute("clve",clave);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:local1";
Connection con = DriverManager.getConnection(url, identificador, clave);
String Agente = request.getHeader("User-Agent");
String Host = request.getRemoteHost();
Statement stmt = con.createStatement();
stmt.executeUpdate("insert into visitas values (" + fecha + "," + "'" + hora + "'" + "," + "'" + Agente + "'" + "," + "'" + Host + "'" + ")");
ResultSet rs = stmt.executeQuery("select count (*) from visitas");
rs.next();
String num = rs.getString(1);
out.println(num);
?>
this code connect to the database with user and password given in another page (post action) and insert into a table information like date, hour, etc...
sorry for my english...