Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

URGENT: My JSP display null value

losintikfosMar 23 2008 — edited Mar 24 2008
Hi experts! below is my bean which fetch the record from the database with setter and getter classes used by the preceding JSP. Anytime i run the project and render the JSP in browser i get null values.

Experts can you spot what i am doing wrong please. I am using Glassfish and netbeans and as you've probably notice apache derby.

package com.sun.rrd;
 
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
 
public class licensee implements Serializable {
 
    private String name;
    private String title;
    private String Code;
    private String title;
    private String email;
    private String contact;
    
    public static Connection getConnection() throws Exception {
        String driver = "org.apache.derby.jdbc.ClientDriver";
        String url = "jdbc:derby://localhost:1527/sample";
        String username = "pass";
        String password = "pass";
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        return conn;
    }
 
    public void ConnectMe() {
        ResultSet rs = null;
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = getConnection();
            String query = "select * from users where user_id = 4 ";
 
            pstmt = conn.prepareStatement(query); // create a statement
            //pstmt.setInt(1, 1001); // set input parameter
            rs = pstmt.executeQuery();
            //extract data from the ResultSet
            while (rs.next()) {
                setIseries_Code(rs.getString(1));
                setTitle(rs.getString(2));
                setEmail(rs.getString(3));
                setContact(rs.getString(4));
                System.out.println(Code + " " + title + " " + email + " " + 
 
contact + " ");
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                rs.close();
                pstmt.close();
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
 
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String geTitle() {
        return title;
    }
 
    public void setTitle(String title) {
        this.recording_title = title;
    }
 
    public String getCode() {
        return this.Code;
    }
 
    public void setCode(String Code) {
        this.Code = Code;
    }
 
    public String getTitle() {
        return this.title;
    }
 
    public void setTitle(String title) {
        this.title = title;
    }
 
    public String getEmail() {
        return this.email;
    }
 
    public void setEmail(String email) {
        this.email = email;
    }
 
    public String getContact() {
        return this.contact;
    }
 
    public void setContact(String contact) {
        this.contact = contact;
    }
 public static void main(String[] args) {
       licensee me = new licensee();
        me.ConnectMe();
    }

}
This is the JSP file
-------------------------------
<jsp:useBean id="param" class="com.sun.rrd.licensee" scope="session"/>
<jsp:setProperty name="param" property="*" />
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
  <center>
    <body>
          <table width="900">
            <tr>
             <td>Code</td>
             <td>Title</td>
             <td>Contact</td>
             <td>Email</td>
            </tr>
                <tr>                
                    <td><%= param.getEmail() %><BR/></td>
                    <td><%= param.getTitle() %></td>
                    <td><%= param.getEmail() %></td>
                    <td><%= param.getEmail() %></td>
                  </tr>
        </table>
    </body>
</center>
</html>
Need you help please.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2008
Added on Mar 23 2008
16 comments
1,530 views