Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP program error  RSS feed

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers...
Here is a error with me..
actully i'm not using that code anywhere in the program..
but i don't know.. still i'm getting the same trouble...


the code of jsp is here

<html>
<head>
<title>Employee regs
</title>
</head>
<%@ page language="java" session="true" import="java.sql.*" %>
<body>
<form name ="form2" method = post action ="http://172.16.0.8:8080/check/lib/edit.html">


<%
String sea = request.getParameter("search");

try
{
try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{out.println(e);
}
String dbURL = "jdbc dbc:li";
Connection dbCon;
dbCon = DriverManager.getConnection(dbURL);
String query = "Select * from userde where name ="+"'"+sea+"'";
Statement stmt = dbCon.createStatement();

ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String name = rs.getString(1);
String add = rs.getString(4);
String email = rs.getString(5);
String phone = rs.getString(6);

out.println(name);
out.println(add);
out.println(email);
out.println(phone);

out.println("Searched Successfully!!") ;

}

dbCon.close();
stmt.close();

}
catch(SQLException e)
{out.println("fucking problem " +e);
}

%>
<input type = "text" name = "name" value= "<%= name%>"
<input type = "text" name = "add" value= "<%= add%>"
<input type = "text" name = "email" value= "<%= email%>"
<input type = "text" name = "phone" value= "<%= phone%>"
<input type = "submit" value = "submit" name = "b1">
</form>
</body>
</html>



the error is here

An error occurred at line: 54 in the jsp file: /check/lib/searc.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Java\tomcat\jakarta\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\check\lib\searc_jsp.java:98: cannot find symbol
symbol : variable name
location: class org.apache.jsp.check.lib.searc_jsp
out.print( name);
^
An error occurred at line: 55 in the jsp file: /check/lib/searc.jsp

Generated servlet error:
C:\Java\tomcat\jakarta\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\check\lib\searc_jsp.java:101: cannot find symbol
symbol : variable add
location: class org.apache.jsp.check.lib.searc_jsp
out.print( add);
^





i don't know what error is this..
can u clear me.. what is the reason for this.?
 
vibhu garg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a pretty first level error in java....
You have defined the variable name,add....etc... in the upper block & variables in once block are not accessible in the outside block.......

When you are trying to access them outside their scope .....compiler is unable to find them & thus the error that can not resolve symbol name, add.......
Error is in the lines

<input type = "text" name = "name" value= "<%= name%>"
<input type = "text" name = "add" value= "<%= add%>"

You can't access name & add variable here........
[ January 05, 2006: Message edited by: vibhu garg ]
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sebo Vidhu!!
It is not working..
what i want to display in the text box is!!

i'm giving something for searching from the database..
it is assigned to the variable "sea"

it searches from the database... userde
and displays name.. add.. email.. and phone of the particular person..


now what i want to do is..
i want to display this textbox..

if i'm giving <% = sea%> i can display the parameter which i've sent from the previous page..
but i'm not able to diplay the variable i've declared in the current page..

can u solve this please..

i want to display the name.. in the text box..
name is what the thing searching from the database!!

please help me!!
 
Peter Sin
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vibhu garg:
This is a pretty first level error in java....


Make your variables in scope.

<html>
<head>
<title>Employee regs
</title>
</head>
<%@ page language="java" session="true" import="java.sql.*" %>
<body>
<form name ="form2" method = post action ="http://172.16.0.8:8080/check/lib/edit.html">


<%
String sea = request.getParameter("search");
String name = "";
String add = "";
String email = "";
String phone = "";

try
{
try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{ out.println(e);
}
String dbURL = "jdbc dbc:li";
Connection dbCon;
dbCon = DriverManager.getConnection(dbURL);
String query = "Select * from userde where name ="+"'"+sea+"'";
Statement stmt = dbCon.createStatement();

ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
name = rs.getString(1);
add = rs.getString(4);
email = rs.getString(5);
phone = rs.getString(6);

out.println(name);
out.println(add);
out.println(email);
out.println(phone);

out.println("Searched Successfully!!") ;

}

dbCon.close();
stmt.close();

}
catch(SQLException e)
{ out.println("fucking problem " +e);
}

%>
<input type = "text" name = "name" value= "<%= name%>"
<input type = "text" name = "add" value= "<%= add%>"
<input type = "text" name = "email" value= "<%= email%>"
<input type = "text" name = "phone" value= "<%= phone%>"
<input type = "submit" value = "submit" name = "b1">
</form>
</body>
</html>
[ January 05, 2006: Message edited by: Peter Sin ]
 
Peter Sin
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Aravind Prasad:

catch(SQLException e)
{out.println("fucking problem " +e);
}



Forget to tell you. You have violate the rule of "To be nice".
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanku ranchers..
now i got the problem..
it is ok now..

this is actully for the purpose of editing the datas in database..

so.. thank u once again!!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!