For Programmers: Free Programming Magazines  


Home > Archive > Java Help > September 2004 > JSP: Classes, methods?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author JSP: Classes, methods?
Spocht

2004-09-23, 8:57 am

Hi there,

I began doing some JSP and trying out something. One of the first
things I learned was what the error-Site of Tomcat 5 looks like... My
problem: The following code is reported to have an error:

<snip>
cannot resolve symbol
symbol : method length (java.lang.String)
location: class org.apache.jsp.test.test.test_jsp
output = length(test);
^
<snap>

The code is:

<%!
String test;
int output;
%>
<%
test = "foo";
output = length(test);
%>
<html>
<head>
<title>Test</title>
</head>
<body>
Test!<br>
<br>
<%= output %><br>
<br>
</body>
</html>

Any ideas? Do I have to import/include classes? Which ones? How?

Thanks for your help!
Tor Iver Wilhelmsen

2004-09-23, 8:57 am

udo.f@gmx.net (Spocht) writes:

> output = length(test);


Java is an object-oriented languiage; this means that methods don't
exist on their own, but as part of objects or classes.

You don't call a function on a structure like you would in C, you use
a method associated with the object:

output = test.length();
Bryce

2004-09-23, 3:59 pm

On 23 Sep 2004 01:17:58 -0700, udo.f@gmx.net (Spocht) wrote:

>Hi there,
>
>I began doing some JSP and trying out something. One of the first
>things I learned was what the error-Site of Tomcat 5 looks like... My
>problem: The following code is reported to have an error:
>
><snip>
>cannot resolve symbol
>symbol : method length (java.lang.String)
>location: class org.apache.jsp.test.test.test_jsp
>output = length(test);
> ^
><snap>
>
>The code is:
>
><%!
>String test;
>int output;
>%>
><%
>test = "foo";
>output = length(test);


try
output = test.length();

>%>
><html>
><head>
><title>Test</title>
></head>
><body>
>Test!<br>
><br>
><%= output %><br>
><br>
></body>
></html>
>
>Any ideas? Do I have to import/include classes? Which ones? How?
>
>Thanks for your help!



--
now with more cowbell
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com