Hi Rob,

Thanx for this - this is great - I may have to use this because I think I
have truly found a bug in Tomcat as this issue is not happening on my Tomcat
3 server. I did a bit more investigation and I found some interesting
things. This is going to be a long email with code and stuff but whoever
wants to read it please do - because the results are weird.

I created the following simple JSP page

<%@ page language="java"
import="javax.crypto.*,java.sql.*,java.net.*,dbc.DBConnectionManager" %>
<%^M
        String query = "select * from patient_info where ref_client = 38 and
pat_lname like '%SM'ITH%';";
        DBConnectionManager connMgr;
        connMgr = DBConnectionManager.getInstance();
        Connection Conn = connMgr.getConnection("podb");
        Statement SQLS = Conn.createStatement();
        ResultSet rs = SQLS.executeQuery(query);
        String col1 = null;
        String col2 = null;
        while(rs.next()) {
                col1 = rs.getString("pat_id");
                col2 = rs.getString("pat_fname");
%>
<%=col1%>: <%=col2%><br>
<br>
<%
        }
        rs.close();
        SQLS.close();
        connMgr.freeConnection("podb",Conn);
%>

As you can see I did a syntax error in the query and  the error comes to the
screen as expected

javax.servlet.ServletException: ERROR:  syntax error at or near "ITH" at
character 74

I said that's weird so I tried to compare my complicated JSP files to what I
have here to see what is different (if I did something wrong)  and I found
this

If I add an include at certain parts of the page - I see the result I was
talking about. For example if I do this:

<jsp:include page="top.html" flush="true">
<%@ page language="java"
import="javax.crypto.*,java.sql.*,java.net.*,dbc.DBConnectionManager" %>
<%^M
        String query = "select * from patient_info where ref_client = 38 and
pat_lname like '%SM'ITH%';";
        DBConnectionManager connMgr;
        connMgr = DBConnectionManager.getInstance();
        Connection Conn = connMgr.getConnection("podb");
        Statement SQLS = Conn.createStatement();
        ResultSet rs = SQLS.executeQuery(query);
        String col1 = null;
        String col2 = null;
        while(rs.next()) {
                col1 = rs.getString("pat_id");
                col2 = rs.getString("pat_fname");
%>
<%=col1%>: <%=col2%><br>
<br>
<%
        }
        rs.close();
        SQLS.close();
        connMgr.freeConnection("podb",Conn);
%>

I get the error page as I should - however If I move the include to below
the <%@ page language="java".... - I get a blank page!!

Now here is where it gets weirder - if I force a java syntax error like as
follows (I corrected the query):

<jsp:include page="top.html" flush="true">
<%@ page language="java"
import="javax.crypto.*,java.sql.*,java.net.*,dbc.DBConnectionManager" %>
<%^M
        String query = "select * from patient_info where ref_client = 38 and
pat_lname like '%SMITH%';";
        DBConnectionManager connMgr;
        connMgr = DBConnectionManager.getInstance();
        Connection Conn = connMgr.getConnection("podb");
        Statement SQLS = Conn.createStatement();
        ResultSet rs = SQLS.executeQuery(query);
        String col1 = null;
        String col2 = null;
        if (col1.equals("yes") {
        //test
       }
        while(rs.next()) {
                col1 = rs.getString("pat_id");
                col2 = rs.getString("pat_fname");
%>
<%=col1%>: <%=col2%><br>
<br>
<%
        }
        rs.close();
        SQLS.close();
        connMgr.freeConnection("podb",Conn);
%>

An error will get thrown to the screen

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /testdb.jsp

/var/lib/tomcat4/work/Standalone/localhost/podims/testdb_jsp.java:57: ')'
expected
        if (col1.equals("yes") {

However if I try to force a null pointer error by correcting my syntax
error - I get a blank screen! If remove the include I get the null pointer
error no problem. The other behaviour I noticed as well is that as I said
before if the include is above the <%@ page language.... piece it works
fine - only if its an html - if its another jsp file - I get a blank screen
as well.

So has anyone else seen this behaviour - is there a fix or a work around -
should I got back to Tomcat 3?? I'm going to try your suggestion Rob and see
if that helps at all, but to me its seems like an issue with the JSP
compiler.

Cheers

Adile

-----Original Message-----
From: Rob Hills [mailto:[EMAIL PROTECTED]
Sent: July 21, 2005 9:36 PM
To: tomcat-user@jakarta.apache.org
Subject: RE: Error 500 messages


Hi Adile,

I did say it was untested, and I've spotted a problem in my code already
(why are bugs so invisible BEFORE you press the send button??!!)

On 22 Jul 2005 at 9:41, Rob Hills wrote:

> Something like the following (untested) in your error.jsp should do the
trick:
>
> <%
>   if (exception == null) {
> %>
>     <H1>A null exception was encountered</H1>
> <%
>   } else {
>     if (exception instanceof SQLException) {
>       Exception e = exception;  // WRONG

        the line above should read:
          SQLException e = (SQLException)exception;

>       while (e != null) {
> %>
>         <P>Error Code: <%=e.getErrorCode()%></P>
>         <P>Message: <%=e.getMessage()%></P>
> <%
>         e = e.getNextException();
>       }
>     } else {
>       // non-sql error handling here...
>     }
>   }
>
> HTH,
>
> Rob Hills
> www.netpaver.com.au
> Western Australia
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


Rob Hills
MBBS, Grad Dip Com Stud, MACS
Senior Consultant
Netpaver Web Solutions
Tel:    (08) 9485 2555
Mob:    (0412) 904 357
Fax:    (08) 9485 2555



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.9.2/54 - Release Date: 7/21/05

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.2/55 - Release Date: 7/21/05


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to