• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error when i run a jsp file

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ricky James
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ricky James
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[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
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic