V
vishal17
I have a strange problem,first i wrote the html code for input values
then i wrote d jsp code as given below for login :
this logincon.jsp is in webapps/test folder
<%@ pageimport="java.sql.*,vishal.dbConn4,java.util.*" %>
<%!
ResultSet rs ;
String sConn;
dbConn4 db;
public void jspInit() {
dbConn4 db = new dbConn4();
sConn = db.DBConnect();
rs = null;
}
%>
<%
String sID = request.getParameter("ID");
String uname =request.getParameter("uname");
String pwd =request.getParameter("password");
//String user=null;
int t=0;
rs = db.getData();
%>
<%
while(rs.next()){
%>
<%
String x=rs.getString(1);
String y=rs.getString(2);
if(x.equals(uname)&&y.equals(pwd))
{%>
<jsp:forward page="x.jsp"/>
<%
}
else{ t=1;
}
}
%>
<%if(t==1) { %>
<jsp:forward page="login1.jsp"/>
<%}%>
-----------------------------------------------------------------------------//------------------------------------------------
i wrote java program dbConn4 as below and put this class file in the
test/web-inf/classes/vishal
package vishal;
import java.sql.*;
public class dbConn4
{
// Member Variables
String uname="root";
String pwd="sai";
String url=
"jdbc:mysql://localhost/vishal";
ResultSet m_RS = null; //
RecordSet Variable
Connection m_conn = null;
public ResultSet getData() {
String sqlStatement = "SELECT
NAME,PWD FROM user" ;
ResultSet temp = executeQuery
(sqlStatement);
return temp;
}
when i compile this code then the following error comes:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 12 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
9: <%!
10: ResultSet rs ;
11: String sConn;
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
An error occurred at line: 15 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
16: sConn = db.DBConnect();
17: rs = null;
18: }
An error occurred at line: 15 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
16: sConn = db.DBConnect();
17: rs = null;
18: }
An error occurred at line: 29 in the jsp file: /tbill/login_conn.jsp
db cannot be resolved
26: int t=0;
27:
28:
29: rs = db.getData();
30:
31: %>
32:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:
92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:
330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:
443)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:
594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
316)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
---------------------------------------------//---------------
i also create database & tables with some entries.....
database connectivity is alright..
plz solve this problem ,i am struggling this for 1week
lots of thank u in advance......................
then i wrote d jsp code as given below for login :
this logincon.jsp is in webapps/test folder
<%@ pageimport="java.sql.*,vishal.dbConn4,java.util.*" %>
<%!
ResultSet rs ;
String sConn;
dbConn4 db;
public void jspInit() {
dbConn4 db = new dbConn4();
sConn = db.DBConnect();
rs = null;
}
%>
<%
String sID = request.getParameter("ID");
String uname =request.getParameter("uname");
String pwd =request.getParameter("password");
//String user=null;
int t=0;
rs = db.getData();
%>
<%
while(rs.next()){
%>
<%
String x=rs.getString(1);
String y=rs.getString(2);
if(x.equals(uname)&&y.equals(pwd))
{%>
<jsp:forward page="x.jsp"/>
<%
}
else{ t=1;
}
}
%>
<%if(t==1) { %>
<jsp:forward page="login1.jsp"/>
<%}%>
-----------------------------------------------------------------------------//------------------------------------------------
i wrote java program dbConn4 as below and put this class file in the
test/web-inf/classes/vishal
package vishal;
import java.sql.*;
public class dbConn4
{
// Member Variables
String uname="root";
String pwd="sai";
String url=
"jdbc:mysql://localhost/vishal";
ResultSet m_RS = null; //
RecordSet Variable
Connection m_conn = null;
public ResultSet getData() {
String sqlStatement = "SELECT
NAME,PWD FROM user" ;
ResultSet temp = executeQuery
(sqlStatement);
return temp;
}
when i compile this code then the following error comes:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 12 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
9: <%!
10: ResultSet rs ;
11: String sConn;
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
An error occurred at line: 15 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
16: sConn = db.DBConnect();
17: rs = null;
18: }
An error occurred at line: 15 in the jsp file: /tbill/login_conn.jsp
dbConn4 cannot be resolved to a type
12: dbConn4 db;
13: public void jspInit() {
14:
15: dbConn4 db = new dbConn4();
16: sConn = db.DBConnect();
17: rs = null;
18: }
An error occurred at line: 29 in the jsp file: /tbill/login_conn.jsp
db cannot be resolved
26: int t=0;
27:
28:
29: rs = db.getData();
30:
31: %>
32:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:
92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:
330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:
443)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:
594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
316)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
---------------------------------------------//---------------
i also create database & tables with some entries.....
database connectivity is alright..
plz solve this problem ,i am struggling this for 1week
lots of thank u in advance......................