R
ramesh
Please help i am having this error for the past 3 day, but i wasn't
able rectify this error, pls help me,
Step 1: my context-->
<Context path="/site" docBase="e:/project" debug="0"
reloadable="true" crossContext="true" />
Step 2:
Files:
e:/project/
registration/
registration1.htm
registration2.jsp
WEB-INF/
web.xml
classes/
UserDetails.class
This is html file(registration1.htm) to send the details to
registration2.jsp file, this file having one bean tag. but the server
raises the error and is Unable to compile the class for JSP
File#1
registration1.htm
<form action="registration2.jsp" method="post" name="reg"
onSubmit="return validate()">
<br>
<table>
<tr>
<td><b>Company Registration Process ...</b></td>
</tr>
</table>
<hr><br>
<table align=center>
<tr>
<td>User/Company name:</td>
<td><input type=text name=userid size=40>*</td>
</tr>
<tr>
<td>Password:</td>
<td><input type=Password name=password>*</td>
</tr>
<tr>
<td>Con Password:</td>
<td><input type=Password name=conPassword>*</td>
</tr>
<tr>
<td> Secret Question: </td>
<td>
<select name=secQuestion>
<Option value=""> ---Select---</option>
<option value="Favourate Pets Name">Favourate Pets
Name</option>
<option value="Favourate Spot">Favourate Spot</option>
<option value="Your Sign">Your Sign</option>
<option value="Alternative Question">Alternative
Question</option>
</select>
</td>
</tr>
<tr>
<td>Alternative Question:</td>
<td><input type=Text name=altQuestion size=40>*</td>
</tr>
<tr>
<td>Hint Answer:</td>
<td><input name=hintAnswer>*</td>
</tr>
<tr>
<td>Current E-Mail Address</td>
<td><input type=text name=emailAdd size=40></td>
</tr>
</table>
<p align=center>
<Input type=Submit name=Send value=" Next ">
<br><br><br><hr>
</form>
File#2
registration2.jsp
<%@ page import="java.util.*" %>
<%
String user_id = request.getParameter("userid");
String password = request.getParameter("password");
String u_sec_ques=request.getParameter("secQuestion");
if (u_sec_ques==null || u_sec_ques=="") {
u_sec_ques=request.getParameter("altQuestion");
}
String u_hint_ans=request.getParameter("hintAnswer");
String email = request.getParameter("emailAdd");
%>
<jsp:useBean id="myUserBean" class="UserDetails" scope="session" >
<jsp:setProperty name="myUserBean" property="userId" value="<%=
user_id %>" />
<jsp:setProperty name="myUserBean" property="password" value="<%=
password %>" />
<jsp:setProperty name="myUserBean" property="question" value="<%=
u_sec_ques %>" />
<jsp:setProperty name="myUserBean" property="ans" value="<%=
u_hint_ans %>" />
<jsp:setProperty name="myUserBean" property="email" value="<%=
email %>" />
</jsp:useBean>
<%
out.println(myUserBean.isExist());
%>
File#3
UserDetails.java
import java.sql.*;
public class UserDetails {
private String firstName = null;
private String lastName = null;
private String sex = null;
private String day = null;
private String month = null;
private Date bdate = null;
private String add1 = null;
private String add2 = null;
private String city = null;
private String state = null;
private String country = null;
private String pin = null;
private String ph1 = null;
private String ph2 = null;
private String fax = null;
private String userId = null;
private String password = null;
private String question = null;
private String ans = null;
private String email = null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
public UserDetails() {}
public void setFirstName(String firsName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setBdate(Date bdate) {
this.bdate = bdate;
}
public void setAdd1(String add1) {
this.add1 = add1;
}
public void setAdd2(String add2) {
this.add2 = add2;
}
public void setCity(String city) {
this.city = city;
}
public void setState(String state) {
this.state = state;
}
public void setCountry(String country) {
this.country = country;
}
public void setPin(String pin) {
this.pin = pin;
}
public void setPh1(String ph1) {
this.ph1 = ph1;
}
public void setPh2(String ph2) {
this.ph2 = ph2;
}
public void setFax(String fax) {
this.fax = fax;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setPassword(String password) {
this.password = password;
}
public void setQuestion(String question) {
this.question = question;
}
public void setAns(String ans) {
this.ans = ans;
}
public void setEmail(String email) {
this.email = email;
}
public boolean isExist() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbcdbc:site_builder");
con.setAutoCommit(false);
}catch(Exception e) {
return true;
}
if(userId != null && !userId.equals("")) {
try {
pstmt = con.prepareStatement("select count(*) from user_table
where user_id=?");
pstmt.setString(1,userId);
rs = pstmt.executeQuery();
rs.next();
int count = rs.getInt(1);
if(count > 0) {
return true;
}
return false;
}catch(Exception e) {
return true;
}
}
return true;
}
public boolean isCreate() {
boolean flag = isExist();
if(flag) {
return false;
}
try {
pstmt = con.prepareStatement("insert into user_table
values(?,?,?,?,?)");
pstmt.setString(1,userId);
pstmt.setString(2,password);
pstmt.setString(3,question);
pstmt.setString(4,ans);
pstmt.setString(5,email);
int count = pstmt.executeUpdate();
if( count > 0 ) {
pstmt = con.prepareStatement("insert into user_det_table
values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt.setString(1,firstName+" "+lastName);
pstmt.setString(2,sex);
pstmt.setString(3,add1);
pstmt.setString(4,add2);
pstmt.setString(5,city);
pstmt.setString(6,state);
pstmt.setString(7,country);
pstmt.setString(8,pin);
pstmt.setString(9,ph1);
pstmt.setString(10,ph2);
pstmt.setString(11,fax);
pstmt.setString(12,userId);
pstmt.setDate(13,bdate);
int count1 = pstmt.executeUpdate();
if(count1 > 0 ) {
con.commit();
return true;
}
else {
con.rollback();
return false;
}
}else {
con.rollback();
return false;
}
}catch(Exception e) {
return false;
}
}
}
able rectify this error, pls help me,
Step 1: my context-->
<Context path="/site" docBase="e:/project" debug="0"
reloadable="true" crossContext="true" />
Step 2:
Files:
e:/project/
registration/
registration1.htm
registration2.jsp
WEB-INF/
web.xml
classes/
UserDetails.class
This is html file(registration1.htm) to send the details to
registration2.jsp file, this file having one bean tag. but the server
raises the error and is Unable to compile the class for JSP
File#1
registration1.htm
<form action="registration2.jsp" method="post" name="reg"
onSubmit="return validate()">
<br>
<table>
<tr>
<td><b>Company Registration Process ...</b></td>
</tr>
</table>
<hr><br>
<table align=center>
<tr>
<td>User/Company name:</td>
<td><input type=text name=userid size=40>*</td>
</tr>
<tr>
<td>Password:</td>
<td><input type=Password name=password>*</td>
</tr>
<tr>
<td>Con Password:</td>
<td><input type=Password name=conPassword>*</td>
</tr>
<tr>
<td> Secret Question: </td>
<td>
<select name=secQuestion>
<Option value=""> ---Select---</option>
<option value="Favourate Pets Name">Favourate Pets
Name</option>
<option value="Favourate Spot">Favourate Spot</option>
<option value="Your Sign">Your Sign</option>
<option value="Alternative Question">Alternative
Question</option>
</select>
</td>
</tr>
<tr>
<td>Alternative Question:</td>
<td><input type=Text name=altQuestion size=40>*</td>
</tr>
<tr>
<td>Hint Answer:</td>
<td><input name=hintAnswer>*</td>
</tr>
<tr>
<td>Current E-Mail Address</td>
<td><input type=text name=emailAdd size=40></td>
</tr>
</table>
<p align=center>
<Input type=Submit name=Send value=" Next ">
<br><br><br><hr>
</form>
File#2
registration2.jsp
<%@ page import="java.util.*" %>
<%
String user_id = request.getParameter("userid");
String password = request.getParameter("password");
String u_sec_ques=request.getParameter("secQuestion");
if (u_sec_ques==null || u_sec_ques=="") {
u_sec_ques=request.getParameter("altQuestion");
}
String u_hint_ans=request.getParameter("hintAnswer");
String email = request.getParameter("emailAdd");
%>
<jsp:useBean id="myUserBean" class="UserDetails" scope="session" >
<jsp:setProperty name="myUserBean" property="userId" value="<%=
user_id %>" />
<jsp:setProperty name="myUserBean" property="password" value="<%=
password %>" />
<jsp:setProperty name="myUserBean" property="question" value="<%=
u_sec_ques %>" />
<jsp:setProperty name="myUserBean" property="ans" value="<%=
u_hint_ans %>" />
<jsp:setProperty name="myUserBean" property="email" value="<%=
email %>" />
</jsp:useBean>
<%
out.println(myUserBean.isExist());
%>
File#3
UserDetails.java
import java.sql.*;
public class UserDetails {
private String firstName = null;
private String lastName = null;
private String sex = null;
private String day = null;
private String month = null;
private Date bdate = null;
private String add1 = null;
private String add2 = null;
private String city = null;
private String state = null;
private String country = null;
private String pin = null;
private String ph1 = null;
private String ph2 = null;
private String fax = null;
private String userId = null;
private String password = null;
private String question = null;
private String ans = null;
private String email = null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
public UserDetails() {}
public void setFirstName(String firsName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setBdate(Date bdate) {
this.bdate = bdate;
}
public void setAdd1(String add1) {
this.add1 = add1;
}
public void setAdd2(String add2) {
this.add2 = add2;
}
public void setCity(String city) {
this.city = city;
}
public void setState(String state) {
this.state = state;
}
public void setCountry(String country) {
this.country = country;
}
public void setPin(String pin) {
this.pin = pin;
}
public void setPh1(String ph1) {
this.ph1 = ph1;
}
public void setPh2(String ph2) {
this.ph2 = ph2;
}
public void setFax(String fax) {
this.fax = fax;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setPassword(String password) {
this.password = password;
}
public void setQuestion(String question) {
this.question = question;
}
public void setAns(String ans) {
this.ans = ans;
}
public void setEmail(String email) {
this.email = email;
}
public boolean isExist() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbcdbc:site_builder");
con.setAutoCommit(false);
}catch(Exception e) {
return true;
}
if(userId != null && !userId.equals("")) {
try {
pstmt = con.prepareStatement("select count(*) from user_table
where user_id=?");
pstmt.setString(1,userId);
rs = pstmt.executeQuery();
rs.next();
int count = rs.getInt(1);
if(count > 0) {
return true;
}
return false;
}catch(Exception e) {
return true;
}
}
return true;
}
public boolean isCreate() {
boolean flag = isExist();
if(flag) {
return false;
}
try {
pstmt = con.prepareStatement("insert into user_table
values(?,?,?,?,?)");
pstmt.setString(1,userId);
pstmt.setString(2,password);
pstmt.setString(3,question);
pstmt.setString(4,ans);
pstmt.setString(5,email);
int count = pstmt.executeUpdate();
if( count > 0 ) {
pstmt = con.prepareStatement("insert into user_det_table
values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
pstmt.setString(1,firstName+" "+lastName);
pstmt.setString(2,sex);
pstmt.setString(3,add1);
pstmt.setString(4,add2);
pstmt.setString(5,city);
pstmt.setString(6,state);
pstmt.setString(7,country);
pstmt.setString(8,pin);
pstmt.setString(9,ph1);
pstmt.setString(10,ph2);
pstmt.setString(11,fax);
pstmt.setString(12,userId);
pstmt.setDate(13,bdate);
int count1 = pstmt.executeUpdate();
if(count1 > 0 ) {
con.commit();
return true;
}
else {
con.rollback();
return false;
}
}else {
con.rollback();
return false;
}
}catch(Exception e) {
return false;
}
}
}