tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wentzel <>
Subject RE: Use of Java Classes in .JSP fails under Tomcat 3.2
Date Wed, 16 Jan 2002 20:49:53 GMT
> When I attempt to access methods defined in Java from a .JSP, 
> I am receiving
> a message that the method is not being found.  For example, I 
> have been
> testing with the following .JSP:
> <%@page import="java.util.*, java.lang.*"%>
> <%
> 		// Test
> 	String myString = "100" ;
> 	int myInt = parseInt(myString) ;
> 	out.println("myInt is " + myInt) ;
> %>
> <html>
> 	<head>
> 		<title>Simple Test of JAVA Classes</title>
> 	<body>
> 	</body>
> </html>
> When I run this .JSP under Tomcat 3.2, I am receiving the 
> following message:
> Error: 500
> Location: /testapps/javaTest.jsp
> Internal Servlet Error:
> org.apache.jasper.JasperException: Unable to compile class for
> JSP/usr/tomcat/work/localhost_8080%2Ftestapps/_0002fjavaTest_0
> 002ejspjavaTes
> Method parseInt(java.lang.String) not found in class
> _0002fjavaTest_0002ejspjavaTest_jsp_0.
>                 	int myInt = parseInt(myString) ;
>                 	                    ^

You can't simply say parseInt("1.00");  you have to let the compiler
know what instance, or in this case static instance, you want to call
the method on.  The reason for this is this method may be defined in
several different class and the compiler won't know which to use.
What the compiler is actually telling you is it looked for a method with
the signature int parseInt(String s) defined in the current class(the JSP).

Therefore, use the following,


This notifies the compiler to use the parseInt method in the Integer
class.  Also, just as a note, the import of java.lang.* is unnecessary.
This is an implicit import.

I would suggest getting a good java book and reading up on the basics of
java before diving head first into servlets, jsp, and Tomcat.  This is a
very core theory in java and it doesn't seem like to fully understand the
core theories of java yet.

Michael Wentzel
Software Developer
Software As We Think -

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message