This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic Jsp

 
gobburi saikrishna
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers

i have done the basic example on jsp from HeadFirst servlets and Jsp.

The code of basic jsp is

Counter.java class//

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

and the Jsp page saved as BasicCounter.jsp
<html>
<body>
<center>the page count is
<%= Counter.getCount()%>
</center>
</body>
</html>
and web.xml file
<web-app>
</web-app>

my doubt is iam getting the error as
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /src/BasicCounter.jsp
Counter cannot be resolved
1: <html>
2: <body>
3: <center>the page count is
4: <%= Counter.getCount()%>
5: </center>
6: </body>
7: </html>

please help me to slove it
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to PackageYourBeans. It used to be possible to keep them in the default package, but no longer.

You also need to import your beans into the JSP.
 
gobburi saikrishna
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
beans are in the default package, is it necessary to keep beans in package.
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure!!! The bean file must be well packaged and try include that file in your JSP file...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic