Can You Please help me where I am getting error.. :(
I am using NetBeans and MicroSoft SQL Server 2005.

HTML CODE

<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
       <form action="movie.jsp" method="POST">
            <p><strong> List Of Movies:-</strong>s</p>
            <select name="moviename">
                <option>powe</option>
                <option>ghi</option>
                <option>xyz</option>
                <option>Troy</option>
                <option>poer</option>
                <option>abc</option>
                <option>pqr</option>
                <option>qwe</option>
                <option>ghj</option>
                <option>RA One</option>
                
            </select>
            <p><strong>PRINT</strong></p>
        <p><input type="radio" name="print" value="blueray" />Blue-Ray Print</p>
        <p><input type="radio" name="print"  value="hd" />HD Print</p>
        <p><input type="radio" name="print" value="dvd" />DVD Print</p>
        <p># copies : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="numofcopies" /></p>      
        <p><input type="submit" value="Check Availability" /></p>
        </form>
    </body>
</html>

JSP CODE

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
<%@page import="java.sql.*" %>
<%@page import="java.io.*" %>
<%@page import="java.util.*" %>
        <jsp:useBean id="con" class="db.connect" scope="request" />
<% String print=request.getParameter("print");
String numofcopies=request.getParameter("numofcopies");
String moviename=request.getParameter("moviename");
 int copynumber=Integer.parseInt(numofcopies.trim());
Connection con1=con.getConnection();
PreparedStatement ps = con1.prepareStatement("select * from MOVIE ");
ResultSet rs = ps.executeQuery();
while(rs.next())
       {
        String moviename1=rs.getString("MOVIENAME");
        String hd = rs.getString("HD");
        String dvd = rs.getString("DVD");
        String bluerayprint = rs.getString("BR");
        int bluerp = Integer.parseInt(bluerayprint.trim());
        int hdp = Integer.parseInt(hd.trim());
        int dvdp = Integer.parseInt(dvd.trim());
        if(moviename.equals(moviename1))
        {      
             if(print.equals("Blue-Ray Print") && (copynumber <= bluerp ))
              {
                response.sendRedirect("bankpage.html");
              }
              if(print.equals("HD Print") && (copynumber <= hdp ))
              {
                response.sendRedirect("bankpage.html");
              }
               if(print.equals("DVD Print") && (copynumber <= dvdp ))
              {
                response.sendRedirect("bankpage.html");
              }
         }
         else
                                 {
                 %>
                 Sorry..Item is not currently available in our Stock...!!!
                 Please wait 5 seconds to redirect to the previous page.
                 Happy Shopping... :)
                 <% }
             }
        %>   
        
  </body>
</html>

Bean Code

package db;
import java.sql.*;
public class connect {
    public Connection getConnection() throws Exception {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:project","sa","123");
        return con;
            
      
    }
    
}

SQL TABLE

[B][U]MOVIE[/U][/B]
MOVIENAME   HD  DVD     BR
powe	    200	200	200
ghi	    65	98	30
xyz	    54	87	50
Troy	    53	87	90
poer	    23	65	70
abc	    23	45	77
pqr	    45	34	56
qwe	    65	43	34
ghj	    34	65	34
RA One	    21	29	342

ERROR GENERATED

HTTP Status 500 -

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 /entertainment/movies/html/movie.jsp at line 34

31:         String bluerayprint = rs.getString("BR");
32:         int bluerp = Integer.parseInt(bluerayprint);
33:         int hdp = Integer.parseInt(hd);
34:         int dvdp = Integer.parseInt(dvd);
35:         if(moviename.equals(moviename1))
36:         {      
37:              if(print.equals("Blue-Ray Print") && (copynumber <= bluerp ))


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

root cause

java.lang.NumberFormatException: null
	java.lang.Integer.parseInt(Integer.java:415)
	java.lang.Integer.parseInt(Integer.java:497)
	org.apache.jsp.entertainment.movies.html.movie_jsp._jspService(movie_jsp.java:93)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.
Apache Tomcat/7.0.11

Your first mistake is making this a scriptlet in a jsp. At the very least use either a Servlet or the sql JSTL tags, better would be to use some application beans. The actual error, however, means that you have an empty field in that row that you are retreiving as a String (and so results in null) and you are parsing that String to a number. Since the reference value null is not a valid String object (and even if it were the value would not be a valid number value) you cannot parse it to a number. Why do you not use getInt, rather than getString. And query the table explicitly (i.e. select col1, col2, ... rather than select *) and use a null check (in oracle it would be something like nvl(col, defaultValue), in Access I don't know and don't feel like checking).

commented: Short but to the point +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.