Respectfully, I submit that the problem is that something works "less well" 
when comparing 5.5 and 5.0
 
 
On 5.0.29, the original poster's page provides this error output: 
 
 
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /foobar.jsp
Generated servlet error:
/usr/local/apps/tomcat-5.0.29/work/Catalina/www.foo.com/_/org/apache/jsp/foobar_jsp.java:52:
 incompatible types
found   : java.lang.Object
required: java.lang.String
                String v1 = session.getAttribute(attr);
                                                ^

which accurately locates both the 'compiled' source error (line 52 of 
/org/apache/jsp/foobar_jsp)  *and* identifies and echos the offending line.   
It "inaccurately" identifies the error as occuring on line 2 of the JSP. 
 
I've just installed 5.5.20 and tried out the patch from this website 
(previously discussed on this list): 
http://www.tfenne.com/jasper/  
 
Unfortunately, I can't get it to work, so I'm either doing something wrong, or 
it won't work with 5.5.20
 
 
For shiggles, I tried the following source JSP: 
 
<%@ page import="java.util.*" %>
<% %>
<%        Object v = new String("b");%>
<%        session.setAttribute("a", v);%>
<% %>
<%        Enumeration e = session.getAttributeNames(); %>
<%        while (e.hasMoreElements()) { %>
<%                String attr = (String) e.nextElement(); %>
<%                String v1 = session.getAttribute(attr); %>
<%                String v2 = session.getValue(attr); %>
<%                out.println("attr: " + attr + " v1:" + v1 + " v2:" +v2 + 
"<BR>\n"); %>
<%        }  %>

 
 
And the output now correctly labelled the line of the JSP in which the error 
occured, but again it neither outputs the line in the 'compiled' source nor 
echoes the actual line in error, as it did under 5.0.x.  Plus, who wants to 
write JSP's like that?
 
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 9 in the jsp file: /index.jsp
Generated servlet error:
Type mismatch: cannot convert from Object to String

An error occurred at line: 10 in the jsp file: /index.jsp
Generated servlet error:
Type mismatch: cannot convert from Object to String


 
________________________________

From: Robert Harper [mailto:[EMAIL PROTECTED]
Sent: Tue 11/28/2006 1:42 PM
To: 'Tomcat Users List'
Subject: RE: How do I print out line of code that caused the error?



The problem is that the JSP is not compiled on the browser. Even if it was,
you would be bound on functionality provided by the particular browser. The
servlet container might send an error in the response but that would be up
to the container provider as well. Because these behaviors are not bound by
standards, you can't count on them to always be there if you once had what
you want. There should be server side logs that will show your problem.

Robert S. Harper
Information Access Technology, Inc.
-----Original Message-----
From: D. Alvarado [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 28, 2006 12:32 PM
To: Tomcat Users List
Subject: Re: How do I print out line of code that caused the error?

Thanks.  So there's absolutely no way within the web browser to print
out the line of code that caused the error?  In the example, the line
i would've liked to see in the web browser would have been:

String v1 = session.getAttribute(attr);

Thanks, - Dave

On 11/28/06, Edoardo Panfili <[EMAIL PROTECTED]> wrote:
> D. Alvarado ha scritto:
> > Hi, I'm using Tomcat 5.5 with Apache 2.  Upon getting jsp compilation
> > errors, I'm not told any inofrmation about the code the causaed the
> > error and the line printed is incorrect.  What do I need to configure
> > to correct this?  For example, this page below:
> >
> > <%@ page import="java.util.*" %>
> > <%
> >        Object v = new String("b");
> >        session.setAttribute("a", v);
> >
> >        Enumeration e = session.getAttributeNames();
> >        while (e.hasMoreElements()) {
> >                String attr = (String) e.nextElement();
> >                String v1 = session.getAttribute(attr);
> session.getAttribute(String) returns an Object
> try:
> String v1 = (String) session.getAttribute(attr);
>
>
> >                String v2 = session.getValue(attr);
> >                out.println("attr: " + attr + " v1:" + v1 + " v2:" +
> > v2 + "<BR>\n");
> >        }   // while
> > %>
> >
> > causes this error.  You can eventually figure out the problem, but
> > "line 2" is not right.
> >
> > =============begin error========================
> > type Exception report
> >
> > message
> >
> > description The server encountered an internal error () that prevented
> > it from fulfilling this request.
> >
> > exception
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP
> >
> > An error occurred at line: 2 in the jsp file: /session_vars.jsp
> > Generated servlet error:
> > Type mismatch: cannot convert from Object to String
> >
> > An error occurred at line: 2 in the jsp file: /session_vars.jsp
> > Generated servlet error:
> > Type mismatch: cannot convert from Object to String
> >
> >
> >
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWra
pper.java:512)
> >
> >
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
77)
> >
> >
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
> >
> >     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
> >     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> >
> > =======================end error======================
> >
>
> If you need to see the generated code for the JSP take a look at
> $tomcat_install_dir$/work/Catalina/
>
> Edoardo
>
> --


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to