javax.servlet.ServletException:

hello I am a n00b to JSP. I am reading up an o'rielly book on jsp.

I have installed tomcat and the directory that came with the book. After reading a while i wanted to make a sample bean of mine and just try it out. But I cant get this to work for the life of me.

The beans .java and .class files are inside

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ora\WEB-INF\classes\comu where comu is the package inside which resides the UserBean.java and UserBean.class

Following is the useBean segment from the jsp page

<jsp:useBean id="user" scope="page" class="comu.UserBean"/>

Everytime I try to access the jsp page i get the following exception

javax.servlet.ServletException: comu/UserBean (wrong name: UserBean)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

please guide me to the solution. I just want to get the sample bean working so I can play around with beans a bit more.

If you need any further information please let me know

[1191 byte] By [bhaarat_javaa] at [2007-10-2 20:10:34]
# 1
Sometimes new beans require a restart of Tomcat.When you use the bean are you doing something likeuser.yourMethod(yourParameter);i.e. using the id of (user) as opposed to the name of the class (UserBean)
angrycata at 2007-7-13 22:51:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

i did restart tomcat after putting the bean under /comu/

this is how i am using the bean in my jsp code

<input type="text" name="date" value="<c:out value ="${user.birthDate}"/>">

<c:if test = "${param.submitted && !user.birthDateValid}">

Do you think i have to make some addition to some .xml files in order for this to work?

bhaarat_javaa at 2007-7-13 22:51:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I do not use JSTL so I cant really help you with this, however, if it works in JSP without XML validation, which the bean directive does, then I dont see why you would need this in JSTL.

Why dont you test it with the code I gave, then you can be sure your package is defined correctly etc.

Then, assuming it works you can concentrate on the JSTL syntax. It seems at the moment you are not sure if it is your syntax, or whether there is an underlying problem.

angrycata at 2007-7-13 22:51:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Thanks for the replies and help. I fixed the problem. I dont know sometimes i love eclipse and in cases like these i HATE it. I imported /comu/ inside eclipse and on top of the java code i said package comu; so what it did was it made another folder INSIDE comu. so it was like this /comu/comu/ and thats where UserBean was being compiled and all. So i just said screw eclipse and compiled using javac from cmd prompt. It works like a charm now. I guess i should have imported the whole WEB-INF folder inside eclipse? Thanks again for the help

bhaarat_javaa at 2007-7-13 22:51:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...