This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Urgent, please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Urgent, please help" Watch "Urgent, please help" New topic

Urgent, please help

raja bhai

Joined: Jun 23, 2001
Posts: 3
I am totally new to JSP.I know Java but not JSP.I was trying to show a table on the browser using JSP.I am using JBuilder and Tomcat webserver
here is the code I have written
This is test.jsp
<form method = post action= "Test2.jsp">
<input type = submit>

<%@ page language="java" %>
<jsp:useBean id = "DbBean" scope="request" class="DbBean" />
<jsp:setProperty name="DbBean" property="*" />
the values from database
<%=DbBean.GetData() %>
package testpackage;
import java.sql.*;
import java.util.*;
import java.text.*;
import java.beans.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.HttpJspBase;

public class DbBean
private String url = "jdbc dbc:JavaDSN";
private String Driver = "sun.jdbc.odbc.JdbcOdbcDriver" ;
private Connection con;
private Statement stmt;
private ResultSet rs;
public DbBean()
public String GetData() throws ClassNotFoundException,SQLException
//registering the driver
Class.forName( Driver );
}catch(ClassNotFoundException e)
con = DriverManager.getConnection(url);
stmt = con.createStatement();
rs = stmt.executeQuery("Select * from Items");
}catch(SQLException e)
String RtnValue = "";
RtnValue = RtnValue +"<tr><td>" + rs.getString(1)+"</td>";
RtnValue = RtnValue+"<td>"+rs.getString(2)+"</td>";
RtnValue = RtnValue+"<td>"+rs.getString(3)+"</td>";
RtnValue = RtnValue+"<td>"+rs.getString(4)+"</td></tr>";
return RtnValue;
In F:\jakarta-tomcat\jakarta-tomcat-3.1.1\jakarta-tomcat\webapps\examples\WEB-INF\classes
I have
In F:\jakarta-tomcat\jakarta-tomcat-3.1.1\jakarta-tomcat\webapps\examples\mytests
I have
test.jsp test2.jsp
at http://localhost:8080/examples/mytests/Test2.jsp
I got the following error
Location: /examples/mytests/Test2.jsp
Internal Servlet Error:
java.lang.IllegalStateException: Response has already been committed
at org.apache.tomcat.core.HttpServletResponseFacade.sendError(
at org.apache.jasper.runtime.JspServlet.unknownException(
at org.apache.jasper.runtime.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.tomcat.core.ServletWrapper.handleRequest(
at org.apache.tomcat.core.ContextManager.service(
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(
Please help. don't laugh at my ignorance.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12759
For one thing: since your class is in a package:
"package testpackage;"
You must import the package
instead of <%@ page language="java" %> use
<%@ page language="java" import="testpackage" %>
Furthermore, you must give the full package in the useBean tag:
instead of
<jsp:useBean id = "DbBean" scope="request" class="DbBean" />
<jsp:useBean id = "DbBean" scope="request" class="testpackage.DbBean" />

author of:
It is sorta covered in the JavaRanch Style Guide.
subject: Urgent, please help
Similar Threads
Trouble connecting to MS Access via ODBC
Errors Running JSP Page
Login Validation In JSP
Drop down box
jdbc value retrieval from a bean and then from a jsp