my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Tomcat and Bean placement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Tomcat and Bean placement" Watch "Tomcat and Bean placement" New topic
Author

Tomcat and Bean placement

Ron Lavery
Greenhorn

Joined: Oct 01, 2011
Posts: 6
I'm doing my first JSP/bean app.

My application is under a new folder called "Hello" which is under the "webapps" folder. I've gotten JSP to work with this. But now I've created a bean, and need to put it somewhere.

I've tried all kinds of places and can't get it to work. Also, does this have anything to do with my CLASSPATH environmental variable?

Other info: Tomcat 7; bean is in a package called "user".

Any help here would be greatly appreciated. thanks

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Ron Lavery wrote:My application is under a new folder called "Hello" which is under the "webapps" folder. I've gotten JSP to work with this. But now I've created a bean, and need to put it somewhere.

The Hello folder is known as the "context root" in this case. That's an important term to remember.

I've tried all kinds of places and can't get it to work. Also, does this have anything to do with my CLASSPATH environmental variable?

Not in the least. Any environment variable is ignored at run-time by Tomcat. It's only relevant when building from the command line.

Other info: Tomcat 7; bean is in a package called "user".

In that case, the class file must be placed at WEB-INF/classes/user/, where WEB-INF is placed in the context root.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ron Lavery
Greenhorn

Joined: Oct 01, 2011
Posts: 6
Thanks, I do have that setup and it's still not working.

More info:

Here's my bean code:


Here's my calling JSP:



Here's my directory structure, and I put the UserData.class in here:

C:\Tomcat7\webapps\Hello\WEB-INF\classes\user


And here's the error message:



Thanks again for any help!



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Ron, welcome to the Ranch!
It's better to UseCodeTags instead of quote tags as code tags maintain indentation and add syntax highlighting; I've replaced them for three of your blocks.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ron Lavery
Greenhorn

Joined: Oct 01, 2011
Posts: 6
Rob Spoor wrote:Ron, welcome to the Ranch!
It's better to UseCodeTags instead of quote tags as code tags maintain indentation and add syntax highlighting; I've replaced them for three of your blocks.


Thanks, got it.

Also, FWIW, I've now got the bean thing working. I could not find anything wrong with my code - - so I did the basic stop/start Tomcat - - and now it works.
 
Don't get me started about those stupid light bulbs.
 
subject: Tomcat and Bean placement
 
Similar Threads
image does not display on JSP page w/ Tomcat server
Tomcat fails to detect jsp changes
How to view servlet generated by tomcat when jsp is compiled
bean problem
where to put my application?