hope this helps u
declare ur connection, statement and resultset variables along with the
other string variables in the declarartion tag
and initialise the same in the code
after that the errors will go
regards
prashant
> -----Original Message-----
> From: Pallavi Mahajan [SMTP:paluindian@r...]
> Sent: Monday, April 23, 2001 4:35 AM
> To: Pro_JavaServer_Pages
> Subject: [pro_jsp] Hey check this code!!!!Urgent
>
> Hello friends,
> Please sonsider this code now.
> Have 2 errors...
>
>
> <html>
> <head>
> </head>
> <%@ page language="java"
> info="PALLAVI's Assignment 2"
> contentType="text/html"
> import="java.lang.Integer, java.util.Vector, java.util.*"
> %>
> <%@ page import="java.util.*"%>
> <%@ page import="java.awt.*"%>
> <%@ page import="java.sql.*"%>
>
> <%!//declare variables
>
> String u1;
> String p1 ;
> String s1 ;
> String m1 ;
> String p2 ;
>
> %>
>
> <body>
> <%
>
> try {
>
> u1 = request.getParameter("UserName");
>
>
> p1 = request.getParameter("Password");
> s1 = request.getParameter("subject");
>
> m1 = request.getParameter("text");
>
>
> }catch (Exception e){
> out.print("Sorry some exception has kkl kk been thrown!!");
> }
> %>
>
>
>
> <p>Material Selected is: <b><%=u1 %></b> </p>
> <p>The Status of the User is : <b><%=p1 %></b></p>
>
> <p>The Status of the User is : <b><%=s1 %></b></p>
> <p>The Status of the User is : <b><%=m1 %></b></p>
>
>
> <%
> try{
> %>
> <%
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Connection
> con=DriverManager.getConnection("jdbc:odbc:MsgBoardODBC","admin","admin");
> Statement stmt=con.createStatement();
> ResultSet rs= stmt.executeQuery("Select Password from Entry_tbl where
> UserName='u1'");
>
>
>
> while(rs !=null)
> {
> while(rs.next())
> {
> String p2=rs.getString("Password");
> }
> }
>
>
>
> if(p2.equals(p1))
> {
> out.println("operation sucessful");
> }
>
> }
>
> catch(Exception e){
> System.out.println(e);
> }
> %>
>
>
> <%
> rs.close();
> stmt.close();
> %>
> </body>
> </html>
>
>
>
> errors are
>
>
>
>
> 500 Internal Server Error
>
> Java Server Page Translation Error
>
> Error during compilation :
>
> C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_sendmail.java:172:
> Undefined variable
> or class name: rs
> rs.close();
> ^
> C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_sendmail.java:173:
> Undefined variable
> or class name: stmt
> stmt.close();
> ^
>
>
>
>
>
>
> I dont know why this is happening. Please help me out!
> bye
> Pallavi
> 2 errors
>