Snehal, the problem must be with your jsp page. Do you call sendRedirect
method after writing to the reponse.
In the Exists method there is a try block and neither you have catch block
nor a throws clause.
Also why are not closing the connection in the Exists method.
----- Original Message -----
From: "Snehal Pandya" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 14, 2003 5:29 PM
Subject: confused
> I am working with a small application.
> I have 3 files.
> first is
> connection.java for JDBC Connection
> custSql.java for sql statements
>
> this the error message
>
> Error: 500
> Location: /wip/CustMaster.jsp
> Internal Servlet Error:
>
> java.lang.IllegalStateException: Response has already been committed
> at
>
org.apache.tomcat.core.HttpServletResponseFacade.sendError(HttpServletRespon
seFacade.java:157)
> at
> org.apache.jasper.runtime.JspServlet.unknownException(JspServlet.java:299)
> at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:377)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:160)
> at
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
> at java.lang.Thread.run(Unknown Source)
> Please help me
>
>
> import connection1 ;
> import java.sql.*;
> public class custsql1
> {
> Connection custcon = null;
> int CustCode=0;
> String CustName = null;
> String CustAdd1 = null;
> Statement custstat = null;
> ResultSet custrs=null;
> String custquery = null;
> boolean exist = false;
> boolean sqlok = false;
> connection1 cust = new connection1();
> public custsql1() {}
> public custsql1(int CustCd) {
> CustCode=CustCd;
> }
> public boolean Exists()
> {
> try
> {
> custquery = "Select * from Customers where
ID
> = " + CustCode;
> custcon = cust.connect();
> if(cust.getconavailable())
> { sqlok = true;
> custstat = custcon.createStatement();
>
> custrs=custstat.executeQuery(custquery);
> exist = false;
> while (custrs.next()){
> exist = true;
> file://CustCode =
custrs.getString(1);
> CustName = custrs.getString(2);
> CustAdd1= custrs.getString(3);
> }
> }
> }
> }
> public String getCustName() {
> return CustName;
> }
> public String getCustAdd1() {
> return CustAdd1;
> }
>
>
>
> coustomerMaster.java
>
> import custsql1;
> public class CustMaster1
> {
> boolean CustInfoKnown;
> boolean CustCodeDefined;
> boolean CustExists;
> private int CustCode;
> private String CustName, CustAdd1, CustAdd2, CustAdd3, CustCity;
> boolean sqlok = false;
> custsql1 CurrCust;
>
> public CustMaster1() {
> CustInfoKnown=false;
> CustCodeDefined=false;
> }
> public CustMaster1 (int CustCd) {
> CustCode=CustCd;
> CustCodeDefined=true;
> CustInfoKnown=false;
> }
> public void SetCustCode(int CustCd) {
> CustInfoKnown=false;
> CustCode=CustCd;
> CustCodeDefined=true;
> }
> public void getCustDetails() {
> boolean InfoAvailable = false;
> if (!CustInfoKnown) {
> if (CustCodeDefined) {
> CurrCust=new custsql1(CustCode);
> CustExists=CurrCust.Exists();
> if(CurrCust.getconavailable())
> { sqlok = true;
> if (CustExists) {
> CustName=CurrCust.getCustName();
> CustAdd1=CurrCust.getCustAdd1();
> CustAdd2=CurrCust.getCustAdd2();
> CustAdd3=CurrCust.getCustAdd3();
> CustCity=CurrCust.getCustCity();
> InfoAvailable=true;
> }
> else {
> InfoAvailable=false;
> }
> }
> else { }}
> else {
> InfoAvailable=false;
> }
> if (!InfoAvailable) {
> CustName="Tea Time";
> CustAdd1="In MSD";
> CustAdd2=" ";
> CustAdd3=" ";
> CustCity="Pink City";
> }
> CustInfoKnown=true;
> }
> }
> public boolean Exists() {
> getCustDetails();
> return CustExists;
> }
> public String getCustName() {
> getCustDetails();
> return CustName;
> }
> public String getCustAdd1() {
> getCustDetails();
> return CustAdd1;
> }
> public boolean conavailable() {
> getCustDetails();
> return sqlok; }
> public boolean code() {
> getCustDetails();
> return CustCodeDefined; }
> public boolean info() {
> getCustDetails();
> return CustInfoKnown; }
>
>
> }
>
> Now a jsp which have the customer object
>
> I am getting error
>
>
> Thanking you all
> Snehal
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
> http://java.sun.com/products/jsp
> http://archives.java.sun.com/jsp-interest.html
> http://forums.java.sun.com
> http://www.jspinsider.com
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com