You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "D. Alvarado" <la...@gmail.com> on 2006/11/28 19:29:20 UTC

How do I print out line of code that caused the error?

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);
                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(JspServletWrapper.java:512)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	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======================

Thanks, - Dave

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


RE: How do I print out line of code that caused the error?

Posted by gb1071nx <gb...@globallyboundless.com>.
Well, since my first email, I read the bugzilla ( http://issues.apache.org/bugzilla/show_bug.cgi?id=37062 ) attached to that website, and apparently this patch was committed to 5.5.13.  But... I can't get it to work. I may or may not have the same problem as the last commentor.  Perhaps I'm not aware of how to put tomcat into "development mode". 
 
I've tried putting a context file here: $CATALINE_HOME\conf\Catalina\localhost\foobar.xml
with : 

<Context reloadable="true">
</Context>

And then accessing http://localhost:8080/foobar/index.jsp  (index.jsp being the page that contains the error)
 
Tomcat doesn't complain about anything on stdout when starting (so assume I got the context file correct), but it also doesn't show me anything different in the stacktrace (and yes, I backed out any patched classes I did).   So unless there's some other incantation to put Tomcat into the correct mood ... 5.5.x compilation error messages are simply not as helpful as 5.0 compilation errors. 
 
While being aware that they are configured quite differently, the 5.x tomcats support the same JSP/Servlet spec version, so perhaps you can use 5.0 in a development environment and use 5.5 for production?  
 
 
________________________________

From: D. Alvarado [mailto:laredotornado@gmail.com]
Sent: Tue 11/28/2006 2:56 PM
To: Tomcat Users List
Subject: Re: How do I print out line of code that caused the error?



Wow, how rare that a newer version should lose this feature.  So the
answer then, if I want the code and the correct line printed out is to
revert to Tomcat 5.0? - Dave

On 11/28/06, gb1071nx <gb...@globallyboundless.com> wrote:
> 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:robert@iat-cti.com]
> 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:laredotornado@gmail.com]
> 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 <ed...@aspix.it> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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





Re: How do I print out line of code that caused the error?

Posted by "D. Alvarado" <la...@gmail.com>.
Wow, how rare that a newer version should lose this feature.  So the
answer then, if I want the code and the correct line printed out is to
revert to Tomcat 5.0? - Dave

On 11/28/06, gb1071nx <gb...@globallyboundless.com> wrote:
> 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:robert@iat-cti.com]
> 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:laredotornado@gmail.com]
> 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 <ed...@aspix.it> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


RE: How do I print out line of code that caused the error?

Posted by gb1071nx <gb...@globallyboundless.com>.
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:robert@iat-cti.com]
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:laredotornado@gmail.com]
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 <ed...@aspix.it> 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
>
> --



RE: How do I print out line of code that caused the error?

Posted by Robert Harper <ro...@iat-cti.com>.
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:laredotornado@gmail.com] 
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 <ed...@aspix.it> 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
>
> --
> edoardo@aspix.it
> AIM: edoardopn
> Jabber: edoardopa@talk.google.com
> tel:075 9142766
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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





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


Re: How do I print out line of code that caused the error?

Posted by "D. Alvarado" <la...@gmail.com>.
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 <ed...@aspix.it> 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(JspServletWrapper.java:512)
> >
> >     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
> >
> >     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
>
> --
> edoardo@aspix.it
> AIM: edoardopn
> Jabber: edoardopa@talk.google.com
> tel:075 9142766
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How do I print out line of code that caused the error?

Posted by Edoardo Panfili <ed...@aspix.it>.
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(JspServletWrapper.java:512) 
> 
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) 
> 
>     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

-- 
edoardo@aspix.it
AIM: edoardopn
Jabber: edoardopa@talk.google.com
tel:075 9142766

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