File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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()
{
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
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
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 - my free Android networking tools app
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
 
Consider Paul's rocket mass heater.
 
subject: Basic Jsp