Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp error

 
sandeep Talari
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to import your 'Counter' class in the jsp,

<%@page import="myPackage.Counter" %>
 
sandeep Talari
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@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()).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic