File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes JSP with Jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "JSP with Jdbc" Watch "JSP with Jdbc" New topic
Author

JSP with Jdbc

dhanil das
Greenhorn

Joined: Sep 04, 2009
Posts: 7
This is ma first JSP code , i got some errors during the program executes
here is the code


Error is :

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

22: if(request.getParameter("action") != null){
23: String bookname=request.getParameter("bookname");
24: String author=request.getParameter("author");
25: stmt.executeUpdate("insert into books_details(ID,BookName,Author) values('"+3+"','"+bookname+"','"+author+"')");
26:
27: rst=stmt.executeQuery("select * from books_details");
28: %>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NullPointerException
org.apache.jsp.BookEntryForm_jsp._jspService(BookEntryForm_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Please help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

A title such as "JSP" is not helpful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
1. org.gjt.mm.mysql.Driver refers to MM MySQL, an outdated third-party driver, you should use Connector/j instead and specify the class name accordingly!

2. Make sure that the connector/J's jar is in wour web app's WEB-INF/lib folder when deployed!

3. If an exception is thrown on the con.createStatement(); line (or before that), stmt will remain null which will result in a NUllPointerException! I'd put the rest of the code in the same try!

4. Don't put java code in a JSP, take a look at the Page Controller, Front Controller and MVC design patterns!


OCJP 6 (93%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP with Jdbc