aspose file tools*
The moose likes JSP and the fly likes simple program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "simple program" Watch "simple program" New topic
Author

simple program

amrit choong
Greenhorn

Joined: Dec 18, 2004
Posts: 24
Hi Friends,
I am just not able to figure out the problem,please help me i would be grateful to you.I am using the following :
tomcat5.5.4
jdk1.5.0
I have attached my *.java file and *.jsp file,very simple program but I
keep getting the error attached herewith.I am just waiting for ur help,
amrit


tabletoolbean.java

package bigjava;

import java.sql.*;
import java.util.*;

public class tabletoolbean
{
Connection con = null;
Statement st = null;
ResultSet rs = null;
public ResultSet connect() throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try{
con = DriverManager.getConnection("jdbc dbc:contacts");

String sql = "SELECT * FROM contacts";
st = con.createStatement();
rs = st.executeQuery(sql);
}
catch (Exception e)
{
e.printStackTrace();
}
return rs;
} // end of connect()

public void disconnect() throws Exception
{
try
{
rs.close();
rs = null;
st.close();
st = null;
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (con != null) {
con.close();
con = null;
}
}
} // end of disconnect

}//end of tabletoolbean


contact.jsp

<%@ page session="true"%>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="ttb" scope="session" class="bigjava.tabletoolbean"/>

<HTML>
<BODY>
<H3>Personal Contacts</H3>
<%
ResultSet rs = ttb.connect();
%>

<P>
<TABLE BORDER=1 CELLPADING=3 CELLSPACING=0>
<TR>
<TH>ID</TH>
<TH>Name</TH>
<TH>Address</TH>
<TH>Telephone</TH>
<TH>Email</TH>
</TR>

<%

//Print the result set

while (rs.next()) {
String id = rs.getString(1);
String name = rs.getString(2);
String address = rs.getString(3);
String telephone = rs.getString(4);
String Email = rs.getString(5);
%>
<TR>
<TD><%= id %></TD>
<TD><%= name %></TD>
<TD><%= address %></TD>
<TD><%= telephone %></TD>
<TD><%= Email %></TD>
</TR>

<%
}
%>
</TABLE>

<%
ttb.disconnect();

%>
</BODY>
</HTML>



Error:

org.apache.jasper.JasperException: /try.jsp(4,0) The value for the useBean class attribute bigjava.tabletoolbean is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1223)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3268)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:189)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
[ December 18, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

"amrit ch",

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
u need to inserrt the following line in ur jsp just after declaring the bean..<jsp:useBean id="ttb" setProperty="*" />
u need to also put getter and setter mehtods for member variable of ur bean class...


SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Add a public Constructor and try to execute.
[ December 19, 2004: Message edited by: srini vasan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
amrit choong
Greenhorn

Joined: Dec 18, 2004
Posts: 24
Sorry Bear B and thanks bhavik and srini,
after 4-5 hours of harwork,my program worked,and to my surprise I did nothing except this line and restarting my tomcat:

<jsp:useBean id="ttb" class="bigjava.tabletoolbean" scope="session"/>

Thanks,bye
 
wood burning stoves
 
subject: simple program