• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

simple program

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a public Constructor and try to execute.
[ December 19, 2004: Message edited by: srini vasan ]
 
amrit choong
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic