|
 |
pro_jsp thread: This solution may help u
Message #1 by bishwa basu <bishwa_bose@y...> on Sun, 22 Apr 2001 21:45:43 -0700 (PDT)
|
|
Hello Pallavi!
Here I am sending u the code. May be this will help u.
U just try it.May be there is some prob with
initialization.
<%
Connection con=null;
Statement st=null;
ResultSet rs=null;
String uname=request.getParameter("uname");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
try{
con
DriverManager.getConnection("Jdbc:Odbc:Emp");
}catch(SQLException ex) {}
try{
st=con.createStatement();
}catch(SQLException se) {}
try{
rs = st.executeQuery("select * from
employee");
}catch(SQLException se) {}
if(rs != null){
while(rs.next())
{
//do what u want
%>
--- Pallavi Mahajan <paluindian@r...> wrote:
> 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
>
>
|
|
 |