wood burning stoves 2.0*
The moose likes JSP and the fly likes jsp error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp error" Watch "jsp error" New topic
Author

jsp error

sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
my counter class

public class Counter
{
private static int count;
public static synchronized int getCount()
{
count++;
return count;
}
}

this is the source file

in jsp

<html>
<body>
your visiting no : <%= Counter.getCount() %>
</body>
</html>

i placed the class file of counter in classes folder of web-inf
and jsp file in the context root of the web application and error it is giving me

is

cannot resolve symbol
probably occurred due to an error in /Counter.jsp line 6:
Your count is : <%=Counter.getCount() %>
out.print(String.valueOf(Counter.getCount() ));

please help me
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

You need to import your 'Counter' class in the jsp,

<%@page import="myPackage.Counter" %>


- Marimuthu Madasamy
sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
you mean the source code of the counter class, if i import like you, what you told mypackage.counter where the container look it for
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

<%@page import%> is just like Java import which you will be doing in your Java class. Either you can use complete class name (myPackage.MyClass.myMethod()) while accessing a class member or you can import the class and use the class name alone (as you did Counter.getCount()).
 
wood burning stoves
 
subject: jsp error