jQuery in Action, 3rd edition
The moose likes JSP and the fly likes Basic Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Basic Jsp" Watch "Basic Jsp" New topic

Basic Jsp

gobburi saikrishna
Ranch Hand

Joined: Jan 21, 2008
Posts: 52
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()
return count;

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

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

Joined: Mar 22, 2005
Posts: 42965
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

Joined: Jan 21, 2008
Posts: 52
beans are in the default package, is it necessary to keep beans in package.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Sure!!! The bean file must be well packaged and try include that file in your JSP file...

Never try to be a hard-worker. Be a smart-worker.
My Blog
I agree. Here's the link: http://aspose.com/file-tools
subject: Basic Jsp
It's not a secret anymore!