Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2005, 01:32 PM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default bean problem

hi friends
i am very young to JSP and to the p2p community. itried a basic bean but got the error "org.apache.jasper.JasperException: /sandipan1/add.jsp(2,0) The value for the useBean class attribute student.javaprogram.RegistrationBean is invalid."

i compile the RegistrationBean.java sucessfully.JAVA_HOME is properly set in my computer.
[u]my JSP page is</u>
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="admition" class="student.javaprogram.RegistrationBean" scope="session" />"
<html>
<head>
<title>add student</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<jsp:setProperty name="admition" property ="studentid" value="<%=request.getParameter("studentid") %>" />
<jsp:setProperty name="admition" property="rollnumber" value="<%=request.getParameter("rollnumber") %>" />
<jsp:setProperty name="admition" property="stream" value="<%=request.getParameter("stream") %>" />

<body>

<% admition.insert_data(); %>

<h3>a new student is registered</h3>
</body>
</html>

[u]and my java program is</u>

package student.javaprogram;

import java.sql.*;
import java.io.*;
import javax.sql.*;
import java.util.*;


public class RegistrationBean {
    private String studentid;
    private String rollnumber;
    private String stream;

    public void setStudentid( String studentid) {
        this.studentid=studentid;
    }
    public void setRollnumber(String rollnumber) {
        this.rollnumber=rollnumber;
    }
    public void setStream(String stream) {
        this.stream=stream;
    }
    public String getStudentid() {
        return studentid;
    }
    public String getRollnumber() {
        return rollnumber;
    }
    public String getStream() {
        return stream;
    }
    public void insert_data()
    {
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con=DriverManager.getConnection("jdbc:odbc:testdsn ","scott","tiger");
            PreparedStatement ps=con.prepareStatement("insert into SANDIPAN VALUES(?,?,?)");
            ps.setString(1,studentid);
            ps.setString(2,rollnumber);
            ps.setString(3,stream);
            ps.executeUpdate();

            }
            catch(Exception e){System.out.println(e.toString());
            }
    }

}

so friend please help me out. DSN is ok and working fine.

thanks in advans.

regards
sandi


 
Old April 4th, 2005, 05:07 PM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi sandy

 property ="studentid"
 property="rollnumber"
 property="stream"

is the way to call the set methods (setstudentid), well each property start with not uppercase, but your java code start withuppercase

i saw this common error, the obvious answer is change your property with uppercase, but some times dont work, strange for me!

so,the answer is to change your set methods in your java file to no uppercase

 setStudentid by setstudentid
 setRollnumber by setrollnumber
 setStream by setstream

if i dont remember try to not use the same names to the variables and methods

i hope that my help can resolve your problem

 
Old April 5th, 2005, 01:02 PM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Dr.
thanks buddy for your suggestion. i do what u suggested but it won't work. i am in a big mess here.


sandi

 
Old April 5th, 2005, 01:22 PM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If u want put a hotmail email to add to my messenger list and help u



DR POMPEII, THE PLACE OF THE OBLIVION OF GOD





Similar Threads
Thread Thread Starter Forum Replies Last Post
stateless bean iralala EJB 0 September 24th, 2008 10:55 PM
Jsp,bean iishu JSP Basics 0 November 17th, 2007 11:21 AM
bean developer kit sushant2002 Java Basics 1 July 26th, 2007 04:55 AM
Problem in bean lookup, no exception avaniamin J2EE 0 November 11th, 2005 05:40 AM
Problem with EJB(Session+Entity bean) hiparry_m J2EE 1 October 15th, 2004 01:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.