This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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 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: 39535
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.

Ping & DNS - updated with new look and Ping home screen widget
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:
subject: Basic Jsp
Similar Threads
jsp error
JSP unable to find the class file
Help for a simple jSP program
HTTP Status 404 - /testJSP1/BasicCounter.jsp
Error accessing jsp page