Sunita Sairaman wrote:
>
> I have a registraton page whose action calls a jsp(process.jsp).
> Now I have written a bean to do form validation which
> I am using in the jsp form as:
>
> <jsp:useBean id="formvalidate" class="formbean" scope="request">
> <jsp:setProperty name="formvalidate" property="*"/>
> </jsp:useBean>
>
> The registration page & the jsp are in the directory:
> /local/home/xxx/docs/test/jsp
>
> The formbean.java & formbean.class are in:
> /local/Java/JRun/jrun/jsm-defaults/classes.
>
> I get the following errors:
>
> /local/Java/JRun/jrun/jsm-default/services/jse/servlets/jsp/testjsp/process.java
> :36: Class jsp.testjsp.formbean not found in type declaration.
> formbean formvalidate=null;
> ^
> > [...]
> Can somebody tell me where I am going wrong?

This is due to how Java deals with classes in the "unnamed" package when
compiling classes that are in a named package. JRun apparently generates
a servlet with a package declaration, and your bean is in the "unnamed"
package. There are two solutions:
1) Add <%@ page import="formbean" %> to you page,
2) Add a package declaration to your bean, e.g. "package com.mycomp;"
   and place the class file in the corresponding subdirectory in the
   classpath (classes/com/mycomp in this example), and modify the
   <jsp:useBean> class attribute accordingly (class="com.mycomp.formbean).

I recommend 2) even though it's more work, since packages help you keep
your code structured and avoid name clashes. A minor detail, but you may
also want to follow the standard Java naming conventions, which say that
class names should start with an uppercase letter, e.g. FormBean, see
<http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html> for details.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to