jsp login page with jdbc connectivity to ms-access database
HI...i hav been trying to get my data from login page and to store in ms-access database..i hav worked out correctly i think..but it is not..i hav also tried of with different formats..is there any expert who could suggest me...
REPLY1.JSP
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@page language="java"%>
<%@page import="java.sql.*"%>
<%
String user = "";
String pwd ="";
Connection con = null;
Statement st = null;
try{
user = request.getParameter("un");
pwd = request.getParameter("pwd");
} Catch(Exception e){
}
if(!user.equals("") && !pwd.equals("")){
try
{
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:pad","admin","");
st = st.executeupdate("Insert into Table8 values (' "+user+" ',' "+pwd+" ' )");
}
Catch(Exception e){
e.printStackTrace();
} finally{
try{
if(st != null)
st.close();
if(con != null && con.isClosed() == false)
con.close();
}Catch(SQLException sqe){
sqe.printStackTrace();
}
}
}
%>
ERROR FOR THIS CODING:::
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
[javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\reply1_jsp.java:72: 'try' without 'catch' or 'finally'
[javac] try{
[javac] ^
Generated servlet error:
[javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\reply1_jsp.java:77: ')' expected
[javac] } Catch(Exception e){
[javac]^
[javac] 2 errors
LAST.JSP
<%@ page import="java.sql.*,java.util.*" language="java"%>
<%
String user = "";
String pwd ="";
Connection con = null;
Statement st = null;
try{
user = request.getParameter("un");
pwd = request.getParameter("pwd");
} catch(Exception exp){
}
if(!user.equals("") && !pwd.equals("")){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:pad","admin","");
st = con.createStatement();
int i =st.executeUpdate("Insert into Table8 values (' "+user+" ',' "+pwd+" ' )");
if(i > 0)
out.println("updated");
}catch(Exception e){
e.printStackTrace();
} finally{
try{
if(st != null)
st.close();
if(con != null && con.isClosed() == false)
con.close();
}catch(SQLException sqe){
sqe.printStackTrace();
}
}
}
%>
ERROR FOR THIS PAGE::
e server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
REPLY.JSP:::
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@page language="java"%>
<%@page import="java.sql.*"%>
<%
try
{
Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:pad");
Statement st = st.executeUpdate("insert into Table8 values (' "+request.getparameter("un")+" ',' "+request.getParameter("pwd")+" ' )");
st.close();
con.close();
}
catch(Exception exp)
{
}
error :::
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
[javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\reply_jsp.java:72: cannot find symbol
[javac] symbol : method getparameter(java.lang.String)
[javac] location: interface javax.servlet.http.HttpServletRequest
[javac] Statement st = st.executeUpdate("insert into Table8 values (' "+request.getparameter("un")+" ',' "+request.getParameter("pwd")+" ' )");
[javac]^
Generated servlet error:
[javac] C:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\__default-web-module-server\org\apache\jsp\reply_jsp.java:72: incompatible types
[javac] found: int
[javac] required: java.sql.Statement
[javac] Statement st = st.executeUpdate("insert into Table8 values (' "+request.getparameter("un")+" ',' "+request.getParameter("pwd")+" ' )");
[javac]^
[javac] 2 errors
PLZ ANY ONE HELP ME TO CORRECT THIS CODING OTHERWISE GIVE ME SOME OTHER COMPLETE CODING..

