Hi all,
i did code in jsp for "change password" when user want to change his password he have to enter his old password and then new password.
if he enter wrong password there will be error msg display "sorry you have entered wrong password, and if he enter correct password msg will display "your password has successfully change", this is the code:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL]http://www.w3.org/TR/html4/loose.dtd[/URL]">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-size: 16px;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style15 {font-family: "Cooper Black"}
.style16 {font-size: 12px; font-weight: bold; }
.style3 {font-size: 18px}
-->
</style>
</head>
<body>
<table width="700" height="735" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td height="132" colspan="4"><img src="images/simple_01.gif" width="700" height="132" alt=""></td>
</tr>
<tr>
<td height="51" colspan="4"><img src="images/simple_02.gif" width="700" height="51" alt=""></td>
</tr>
<tr>
<td height="233" colspan="2" background="images/simple_03.gif"><table width="185" border="0" align="center">
<tr>
<td><form name="form1" method="post" action="LogInPage.jsp">
<table width="189" height="177" border="0" align="center">
<tr>
<td><div align="right"></div>
<div align="right"><span class="style1">Log In</span></div></td>
<td> </td>
</tr>
<tr>
<td width="100"><div align="right"><span class="style16">User Name:</span></div></td>
<td width="90" align="right"><div align="left">
<input name="txtUserName" type="text" id="txtUserName" size="10">
</div></td>
</tr>
<tr>
<td><div align="right"><span class="style16">Password:</span></div></td>
<td><input name="txtPass" type="password" id="txtPass" size="10"></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input type="submit" name="Submit" value="Log In">
<input type="reset" name="Reset" value="Reset">
</div></td>
</tr>
<tr>
<td height="43" colspan="2"><div align="center"><a href="ChangePassword.htm">ChangePassword</a></div></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
<td rowspan="2" background="images/simple_04.gif"><table width="445" border="0">
<tr>
<td width="439"><div align="center">
<p>
<p>
<%
Connection conn;
Statement stm = null;
String r = "";
ResultSet rs = null;
String user=request.getParameter("txtUser");
String pass=request.getParameter("txtOldPass");
String newpass=request.getParameter("txtNewPass");
r = "update PersonalInfo set Password1 ='" + newpass + "' where UserName = '" + user + "' and Password1 = '" + pass+ "'";
try
{
sqlStat="SELECT * from PersonalInfo where UserName='" +user+ "' and Password1='" +pass+ "'";
out.print(sqlStat);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:liwa");
// rs.next();
stm = con.createStatement();
stm.executeUpdate(r);
rs = stmt.executeQuery(sqlStat);
if (!rs.next())
{
out.println("you have entered wrong password");
out.println("<a href=ChangePassword.htm>Click here to try again</a>");
}
else
{
out.println("Password Changed Successfully<br/>");
out.print("<a href='Admin.htm'> Home </a>");
}
}
rs.close();
conn.close();
catch (Exception e){
out.println("There is an error" + e.getMessage());
}
%>
</p>
<p> </p>
</div></td>
</tr>
<tr>
<td><div align="justify"><span class="style15"></span></div></td>
</tr>
</table></td>
<td rowspan="3" background="images/simple_05.gif"> </td>
</tr>
<tr>
<td height="298" colspan="2" background="images/simple_06.gif"><table width="200" border="0" align="center">
<tr>
<td><form name="form2" method="post" action="">
<table width="200" height="245" border="0" align="center">
<tr>
<td width="122"><div align="right"><span class="style1">Reservation </span></div></td>
<td width="68" height="36"> </td>
</tr>
<tr>
<td><div align="right"><span class="style16">Check In Date:</span></div></td>
<td height="21"> </td>
</tr>
<tr>
<td colspan="2"><div align="center"><span class="style3">
<select name="select" size="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="select" size="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select name="select" size="1">
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select>
</span><span class="style3"> </span></div></td>
</tr>
<tr>
<td><div align="right"><span class="style16">Check Out Date:</span></div></td>
<td> </td>
</tr>
<tr>
<td colspan="2"><div align="center"><span class="style3">
<select name="select" size="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="select" size="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select name="select" size="1">
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select>
</span></div></td>
</tr>
<tr>
<td><div align="right"><span class="style16">Room Type:</span></div></td>
<td> </td>
</tr>
<tr>
<td colspan="2" valign="bottom"><div align="center"><span class="style3">
<select name="select" size="1">
<option value="King">King</option>
<option value="Big Double">Big Double</option>
<option value="Small Double">Small Double</option>
<option value="Double">Double</option>
</select>
</span></div></td>
</tr>
<tr>
<td height="35" colspan="2"><div align="center"><span class="style3">
<input type="submit" name="Submit" value="Check Availibility">
</span></div></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
<tr>
<td background="images/simple_07.gif"> </td>
<td colspan="2" background="images/simple_08.gif"> </td>
</tr>
<tr>
<td><img src="images/spacer.gif" width="13" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="194" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="468" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="25" height="1" alt=""></td>
</tr>
</table>
</body>
</html>
but this code doesnt display right, this error display:
An error occurred at line: 70 in the jsp file: /saroo/site/ChangePassAction.jsp
Generated servlet error:Syntax error, insert "Finally" to complete TryStatement
An error occurred at line: 70 in the jsp file: /saroo/site/ChangePassAction.jsp
Generated servlet error:Syntax error, insert "}" to complete Block
Generated servlet error:Syntax error on tokens, delete these tokens
Generated servlet error:Syntax error on token "finally", delete this token
plllllz help :)