aspose file tools*
The moose likes JSP and the fly likes error when i run a jsp file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "error when i run a jsp file" Watch "error when i run a jsp file" New topic
Author

error when i run a jsp file

Ricky James
Ranch Hand

Joined: Mar 26, 2007
Posts: 83
Hello,

I am trying some sample applications that came with Sams Teach Yourself JSP.

When I run one of these I get the following error:

org.apache.jasper.JasperException: /ch07/ch07_09.jsp(9,8) The value for the useBean class attribute beans.ch07_07 is invalid.

The jsp file that I have is pasted below. Is there something wrong with the path. Because the javabean was compiled correctly and I have saved the file under the folder of Tomcat - webapps\Sams-TY-JSP\ch07\WEB-INF\classes\beans
while the jsp page is in webapps\Sams-TY-JSP\ch07

I ran a few other examples and they ran ok. But with this one I am having problems.

Can someone please advise what is wrong here.

Thanks
Ricky

<HTML>
<HEAD>
<TITLE>Using Beans and Session Scope</TITLE>
</HEAD>

<BODY>
<H1>Using Beans and Session Scope</H1>

<jsp:useBean id="bean1" class="beans.ch07_07" scope="session" />

<%
bean1.setCounter(bean1.getCounter() + 1);
%>
The counter value is: <jsp:getProperty name="bean1" property="counter" />
</BODY>
</HTML>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ricky James:
and I have saved the file under the folder of Tomcat - webapps\Sams-TY-JSP\ch07\WEB-INF\classes\beans


You saved the .class file under that directory, right?
Not just the .java file?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ricky James
Ranch Hand

Joined: Mar 26, 2007
Posts: 83
Originally posted by Ben Souther:


You saved the .class file under that directory, right?
Not just the .java file?


Yes it has the class file and also the java file.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

The .java file is completely unecessary. You should only be putting the .class files there.

So you most definitely have the file:



in the WEB-INF of the current context (web app)?

P.S. Please don't use bold to post code. It makes is incredibly difficult to read. Rather, use UBB code tags. Please read this for more info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Shouldn't your application structure be something like :
"webapps\Sams-TY-JSP\WEB-INF\classes\ch07\beans"

The WEB-INF directory is supposed to be at the root of your application (called Sams-TY-JSP).

You would then have to change the package declaration of your bean files into :


And then in your JSP files as well :



PS : ch07_07 is a very depressing name for a class ;) Something like "Ch07Ex07.java" would be more like it.


[My Blog]
All roads lead to JavaRanch
Ricky James
Ranch Hand

Joined: Mar 26, 2007
Posts: 83
Originally posted by Bear Bibeault:
The .java file is completely unecessary. You should only be putting the .class files there.

So you most definitely have the file:



in the WEB-INF of the current context (web app)?

P.S. Please don't use bold to post code. It makes is incredibly difficult to read. Rather, use UBB code tags. Please read this for more info.


Thanks for the reply Bear. I'll use UBB tags from now on.

About the exercise:

Yes I most definitely have the file in that folder. And I am really confused why this isn't working.

Thanks again.
Rikcy
Ricky James
Ranch Hand

Joined: Mar 26, 2007
Posts: 83
Originally posted by Satou kurinosuke:
Shouldn't your application structure be something like :
"webapps\Sams-TY-JSP\WEB-INF\classes\ch07\beans"

The WEB-INF directory is supposed to be at the root of your application (called Sams-TY-JSP).

You would then have to change the package declaration of your bean files into :


And then in your JSP files as well :



PS : ch07_07 is a very depressing name for a class ;) Something like "Ch07Ex07.java" would be more like it.


Thanks for the reply Satou.

I had the class files in webapps\Sams-TY-JSP\ch07\WEB-INF\classes\beans. Following your advice I copy-pasted the folder ch07 in webapps directory. And now it is working!!

I got it, I think!

Thanks again.
Ricky
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

[qutoe]I got it, I think!
Make sure you really got it ;) You'd better understand how web applications are structured to avoid hair-pulling problems.
Ricky James
Ranch Hand

Joined: Mar 26, 2007
Posts: 83
Originally posted by Satou kurinosuke:
[qutoe]I got it, I think!

Make sure you really got it ;) You'd better understand how web applications are structured to avoid hair-pulling problems.

Thanks for the advice. You are correct.

I am doing some reading on this topic.

Cheers
Ricky
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Satou kurinosuke:
Shouldn't your application structure be something like :
"webapps\Sams-TY-JSP\WEB-INF\classes\ch07\beans"


Nice catch.
I missed that in the original post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error when i run a jsp file