I'm a beginner to JSP . The following is my simple JSP and Java code . When i try to run this JSP it is giving and error
"Unable to compile class for JSP" . But if my java code doesnot have any database access it works fine. Please Help.
Also could any body get me some more insight on the SCOPE in JSP( what are all the different types and what it actually means) . I only know about scope="session" .
Appreciate your help
JSPcode
<jsp:useBean id="sample" scope="session" class="ActLogins" />
<HTML>
<HEAD>
<TITLE>PRSAS appraisal</TITLE>
</HEAD>
<body>
<H1> This is a sample page </h1>
<%@ page language="java" %>
<%=sample.getLastname()%>
<%=sample.getFirstname()%>
</BODY>
</HTML>
Java class code
mport java.sql.*;
public class ActLogins{
String message ;
Connection connection;
String sEmployeeInfo[] = new String[12];
String lastname;
String firstname;
public ActLogins(){
this.createConnection();
this.validateUserId("1233456");
}
public void setEmpno(String Empno) {
validateUserId(Empno);
}
public void createConnection() {
String sURL = "jdbc:weblogic:mssqlserver4:sastest@synsql2:1433";
String sUserId = "sastest_dbo";
String sPassword = "sastest_dbo";
try {
Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
connection = DriverManager.getConnection(sURL, sUserId, sPassword);
} catch(Exception e) {
message = e.getMessage();
return;
}
}
public void validateUserId(String sEmpNo) {
Statement statement ;
ResultSet rs;
try {
String sqlStmt = "{call USP_SELLOGONPW '" + sEmpNo +"'}";
statement = connection.createStatement();
rs = statement.executeQuery(sqlStmt);
if (rs.next()) {
sEmployeeInfo[0] = rs.getString(1).trim(); //Job Code
sEmployeeInfo[1] = rs.getString(2).trim(); //Employee Last Name
sEmployeeInfo[2] = rs.getString(3).trim(); //Employee First Name
sEmployeeInfo[3] = rs.getString(4).trim(); //Employee Middle Name
sEmployeeInfo[4] = rs.getString(5).trim(); //Password text
sEmployeeInfo[5] = rs.getString(6).trim(); //Company code
sEmployeeInfo[6] = rs.getString(7).trim(); //Branch Code
sEmployeeInfo[7] = rs.getString(8).trim(); //Department Code
sEmployeeInfo[8] = rs.getString(9).trim(); //Unit Code
sEmployeeInfo[9] = rs.getString(10).trim(); //CSA_ADMIN_IND
sEmployeeInfo[10] = rs.getString(11).trim(); //Active Indicator
sEmployeeInfo[11] = rs.getString(12).trim(); //Manager Code
}
} catch(Exception e) {
message = e.getMessage();
return;
}
}
public String getLastname() {
lastname= sEmployeeInfo[1];
return lastname;
}
public String getFirstname() {
firstname= sEmployeeInfo[2];
return firstname;
}
}
Thanks
Ajan
