I would bet you are throwing an exception on the rs.getString(1) which is
causing you to run your getOutputStream() code and masking the original
exception with an IllegalStateException.  Try logging the exception to a
file or the console before calling getOutputStream in your exception
handler.
    (*Chris*)

----- Original Message -----
From: Weigen Jin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 26, 1999 11:03 AM
Subject: Re: encodeUrl problem with parameter


> Cezar,
>
>         You are right.  I have getOutputStream() in the exception handling
> section.
>
>         However, the problem still remains.
>
>         If I am using rs.getString(1),
>         it goes to exception handling,
>         now saying there is no data found.
>
>         If I used a value such as 719 instead of rs.getString(1),
>         it works and displays all the rows in a table.
>
>         Anybody who did this successfully, please let me know.
>
> Weigen
>
>
============================================================================
> =================
> The code is as follws:
>
> ... connect to db ... get resultset ...
>
> try {
>         boolean more = rs.next ();
>         while (more) {
>                 out.println("<tr>");
>                 out.println("<td Align=\"Left\"><a href=\"" +
>                 response.encodeUrl("/servlets/admin.AccountEdit?bankcode="
+
> rs.getString(1)) +
>                         //
> response.encodeUrl("/servlets/admin.AccountEdit?bankcode=771") +
>                 "\">" + rs.getString(1) + "</a></td>");
>                 out.println("<td Align=\"Left\">" + rs.getString(2).trim()
+
> "</td>");
>                 out.println("<td Align=\"Left\">" + rs.getString(3).trim()
+
> "</td>");
>                 out.println("<td Align=\"Left\">" + rs.getString(4).trim()
+
> "</td>");
>                 out.println("</tr>");
>                 more = rs.next ();
>         }
> }
> catch(Exception e)
> {
>         out.println ( "<html><body>" );
>         out.println ( "Error occured in database: <b>" + e.getMessage() +
> "</b>");
>         out.println ( "</body></html>" );
> }
>
>
>
>
>
> -----Original Message-----
> From: Cezar Totth [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 26, 1999 10:14 AM
> To: [EMAIL PROTECTED]
> Subject: Re: encodeUrl problem with parameter
>
>
> Hi,
>
> You probably call both getOutputStream() and getWriter() on the same
> request. The javax.servlet.ServletResponse API states that an
> IllegalStateException should be thrown if you try to use them both
> during the same request.
>
> Cezar
>
> On Thu, 25 Mar 1999, Weigen Jin wrote:
>
> > Hi,
> >
> >         It seems such a simple one line, but I just can not get it works
> > (internal error).
> >         (       rs.getString(1) is pulled out of from a SQL db  )
> >
> >                 out.println("<td Align=\"Left\"><a href=\"" +
> >
response.encodeUrl("/servlets/admin.AccountMgmt?bankcode="
> +
> > rs.getString(1)) +
> >                 "\">" + rs.getString(1) + "</a></td>");
> >
> >         if I replace rs.getString(1) with a value like 719 as follows
> >
> >
> > response.encodeUrl("/servlets/admin.AccountEdit?bankcode=719") +
> >
> >         it works and displays the values in the table.
> >
> >         Look at log file, it says
> >
> >         [25/03/1999 17:31:04:219 EST] java.lang.IllegalStateException:
> > Already called getWriter
> >         at java.lang.Throwable.<init>(Compiled Code)
> >         at org.apache.jserv.JServConnection.getOutputStream(Compiled
Code)
> >         at admin.AccountMgmt.service(Compiled Code)
> >         at javax.servlet.http.HttpServlet.service(Compiled Code)
> >         at org.apache.jserv.JServConnection.run(Compiled Code)
> >         at java.lang.Thread.run(Compiled Code)
> >
> >
> >         Any ideas ?
> >
> >         (I am using Apache / Jserv).
> >
> > Thanks.
> >
> > Weigen
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
>
> Cezar Totth                             email:  [EMAIL PROTECTED]
>                                         Fax:    (401) 220 33 95
> Genesys Software Romania                Phone:  (401) 638 49 44
> Stefan Furtuna 169, sect.6
> cod 77171, Bucharest
> Romania
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to