Hi,
Not sure I'm right but some JDBC drivers become angry if you call
twice resultset.getString(1) on the same row. Try to save the result
on first getString(1) in a String variable and print that variable within
html..
Yup, even java.sql.ResultSet apidoc tells that..
Cezar
On Fri, 26 Mar 1999, Weigen Jin wrote:
> 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
>
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