1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

jsp

Discussion in 'Meet and Greet' started by jramprasad, Oct 5, 2009.

  1. jramprasad

    jramprasad New Member

    Joined:
    Oct 5, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Apache Tomcat/5.5.28 - Error reporthi good AM to every one

    this is my jsp code
    HTML:
    <%@ page language="java" contentType="text/html"%>
    <%@ page import="connjsp.jspconn"%>
    <%@ page import="java.sql.ResultSet"%>
    
    <html>
    <body>
    
    <br>
    <br>
    <table align="center" border="3">
    
    <tr><td>Name </td></tr>
    <%
        ResultSet rs;
        jspconn js = new jspconn();
        rs=js.viewdata();
    
    while( rs.next())
        {
         
       String rd=rs.getString(1);
    out.println("rd");
        
         }%>
        
     <tr><td><% out.println(rs.getString(1)); %></td></tr>
    
    </table>
    </body>
    </html>
    
    My java file
    Code:
    package connjsp;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.sql.SQLException;
    
    public class jspconn
    {
    
    
    String sql;
    Connection connection;
    Statement stmt;
    ResultSet rs;
    
        public ResultSet viewdata()
        {
    
    
        try {
    
            
            
            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);
    
    // Create a connection to the database
            String serverName = "localhost";
            String portNumber = "1521";
            String sid = "TEST";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
            String username = "MANAGER";
            String password = "ORACLE";
            connection = DriverManager.getConnection(url, username, password);
        System.out.println("connected");
          stmt=connection.createStatement();
          sql="select * from emp";
          rs=stmt.executeQuery(sql);
          
    
        } catch (ClassNotFoundException e) {
            // Could not find the database driver
        } catch (SQLException e) {
            // Could not connect to the database
        }
          return rs;
        }
    }
    

    Executing my jsp code the following errors will thrown. Please anybody knows the solution please forward me .



    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    root cause
    java.lang.NullPointerException org.apache.jsp.showemp_jsp._jspService(showemp_jsp.java:61) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
     
    Last edited by a moderator: Oct 5, 2009

Share This Page