File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlet-jdbc - internal servlet error (error:500) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet-jdbc - internal servlet error (error:500)" Watch "servlet-jdbc - internal servlet error (error:500)" New topic
Author

servlet-jdbc - internal servlet error (error:500)

Raghav
Greenhorn

Joined: Jul 24, 2001
Posts: 14
hi,
i am trying a small program on interaction with jdbc and servlet , I am having a html page with a button , which when pressed invokes a servlet through post method which prints out a list of book in the database with its author,isbn etc. when i load the html page and click the button , i get a error error:500 ,the error looks as following:
Error: 500
Internal Servlet Error:
java.lang.IllegalAccessException: booklist
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.web.core.ServletWrapper.loadServlet(ServletWrapper.java:90)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:109)
at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
at com.sun.web.core.Context.handleRequest(Context.java:375)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:135)
if any body can solve the problem ,i would be great , i am running the program on win98,jsdk2.1 and jdk1.3
thanks
raghav
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
the error 500 means that your servlet has been found but some error ocurred in it. Problably your servlet has some error or some code it references has it. If you publish the code it�s gonna be easyer to help.
Raghav
Greenhorn

Joined: Jul 24, 2001
Posts: 14
hi,
i am attaching the code of the html page calling the servlet and the servlet code ,please help me with the problem
html page code:
<html>
<head>
<title>New Page 1</title>
</head>
<body>
<form method="POST" action="http://localhost:8080/examples/servlet/booklist">
<p><input type="submit" value="ShowBooks" name="B1"></p>
</form>
</body>
</html>
servlet code:
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class booklist extends HttpServlet
{
Connection dbconn;
Statement st;
ResultSet rs;
PrintWriter pw;
public void init(ServletConfig cfg) throws ServletException
{
try
{
super.init(cfg);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dbconn=DriverManager.getConnection("jdbc dbc:bookstore");
}
catch(SQLException se)
{
}
catch(ClassNotFoundException ce)
{
}
}
//public void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
//{
//doPost(request,response);
//}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
try
{
st=dbconn.createStatement();
String query = "Select a.lastname,a.firstname,b.isbn,c.title,d.name from authors a,auth_books b, books c,publishers d where a.authid=b.authid AND b.isbn = c.isbn AND c.pub_code = d.pub_code";
rs = st.executeQuery(query);
response.setContentType("text/html");
pw = response.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("<title>");
pw.println("List of Books ");
pw.println("</title>");
pw.println("</head>");
pw.println("<body bgcolor = lightblue>");
pw.println("<table border=1>");
pw.println("<tr><th>ISBN</th><th>Title</th><th>Author</th><th>Publisher</th></tr>");
while(rs.next())
{
pw.println("<tr>");
pw.println("<td>");
pw.println(rs.getString("isbn"));
pw.println("</td>");
pw.println("<td>");
pw.println(rs.getString("title"));
pw.println("</td>");
pw.println("<td>");
pw.println(rs.getString("lastname")+""+rs.getString("firstname"));
pw.println("</td>");
pw.println("<td>");
pw.println(rs.getString("name"));
pw.println("</td>");
pw.println("</tr>");
}
pw.println("</table>");
pw.println("</body>");
pw.println("</html>");
}
catch(SQLException se1)
{
}

}
public void destroy()
{
try
{
pw.close();
rs.close();
dbconn.close();
}
catch(Exception e){}
}
}
thanks for the help
raghav
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
First check if you corrected register the jdbc dbc:bookstore in the control panel Data Sources, than check all the columns names and types you�re trying to recover from the database (i.e rs.getString("isbn"),etc), and don�t let the catch statements empty, allways print the stackTrace and or getMessage ex:
catch(SQLException sqle)
{
sqle.printStackTrace();
System.out.println(sqle.getMessage());
}
and check the server console window.
Raghav
Greenhorn

Joined: Jul 24, 2001
Posts: 14
hi ,
i checked all the thing still i am getting the Error:500 thing ,Internal Servlet Exception , it says it is a illegalaccessexception, i tried the same code as a jdbc application it worked fine , but when used with servlet its giving trouble , what can be the problem be , any way thanks for your help
raghav
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Try to pass a login and password even empty to the database ex:
Connection con = DriverManager.getConnection(url,
"yourLogin", "yourPassword");
or

Connection con = DriverManager.getConnection(url,
"", "");
cause looks like it�s asking for one
Raghav
Greenhorn

Joined: Jul 24, 2001
Posts: 14
hi,
great man , after i give the blank username and password in the parameter it has started working , was it the javasecurity policy which was stopping it . But when i run it as a application it works fine .any way thanks man , will be back with more queries.
raghav
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

man!!!
looks like you are cheating on us.......how could you....
stick to javaranch and get your solutions....
Heheheh.....just kidding!
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet-jdbc - internal servlet error (error:500)