Computer programming

Computer programming

Computer programming news and links

Problem with JSP File

Hello,

I am having a problem with the code posted below. When I try to run the jsp file in firefox I get this error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /JSP9.jsp at line 29

26:
27: String name=request.getParameter("name");
28: //stmt.executeUpdate("insert into Rot(name) value('"+name+"')");
29: rst=stmt.executeQuery("select name from Rot");
30:
31:
32: %>


Any help would be appreciated. Rot is the name of a test database on my system created by MySQL. I am also running Tomcat on my computer.








<%@ page language="java" import="java.sql.*"%>


<%
String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();


Connection con=null;
ResultSet rst=null;

Statement stmt=null;

try{
String url="jdbc:mysql://localhost/David?user=deepak&password=deepak";


con=DriverManager.getConnection(url);
stmt=con.createStatement();
}catch(Exception e){
System.out.println(e.getMessage());
}

if(request.getParameter("action") == null){


String name=request.getParameter("name");
//stmt.executeUpdate("insert into Rot(name) value('"+name+"')");
rst=stmt.executeQuery("select name from Rot");


%>



<html>
<body>
<center><h2>Books List</h2>
<table border="1" cellspacing="0" cellpadding="0">

<tr><td><b>Id</b></td><td><b>Name<b></td></tr>
<%
int no=1;

while(rst.next()){

%>

<tr><td><%=no%></td>
<td><%=rst.getString("name")%></td></tr>

<%
no++;
}

rst.close();
stmt.close();
con.close();



%>

</table>
</center>
</body>
</html>
<else>

return 1;


<%>
Sponsors
Comments
Be the first to leave a comment!
Add a Comment:
Already a member? Log In
Sponsors
About the Author

8 Kudos
Top Geek Articles
Celebrities on the Phone
Cell phones are to celebrities like bats are to baseball: no one runs too far without them.
Why every guy should buy their girlfriend Wii Fit.
Gratuitous...
Hot Geeks -- The Sexiest Geeky Girls
These girls are gorgeous AND they'll play Warcraft with you. Doesn't get much better than that.
More From Zimbio
Copyright © 2009 - Zimbio, Inc. Some rights reserved.