不应该的,你看你的代码方法大小写是否正确。方法名称是否正确。方法是否为公有(public)的

解决方案 »

  1.   

    编译了吗?
    bean里为什么要加main()方法呀?
      

  2.   

    第一个文件:DOGException.javapackage p1.p1;public class DOGException extends Exception
    {

    public  int Error; /**
     * Constructs a DOG exception that contain
     * an error number returned by DOG device driver
     *
     * @param ErrorNumber   Value returned by last call to DOG device driver.
     */

    public DOGException( int ErrorNumber )
    {
    super( "Dog Operation Error " + ErrorNumber );
    Error = ErrorNumber;
    }
    }第二个文件:GSDOG.java
    package p1.p1;public class GSDOG 
    {

            //in most cases, this Global variable should be set zero.
            public  int DogCascade; //The globle variable DogAddr indicates the first memory
    //address(range from 0 to 199) of user area in the MicroDog
    //The sum of DogAddr and DogBytes should not exceed 200
    public  int DogAddr;

    //The globle variable DogBytes indicates the number of bytes
    //in reading/writing operation or convertion
    //The sum of DogAddr and DogBytes should not exceed 200
    public  int DogBytes;

    //The globle variable DogCode refers to the user code in
    //the MicroDog and can be changed by DOGEDIT.exe
    public  int DogPassword;

    //The globle variable refers to the result of convererting operation
    public  long DogResult;

    //the globle variable DogData refers to the pointer variable 
    //which points to the data for writing/reading or converting

    public byte[] DogData;

    public GSDOG()
    {
    }


       /**
    * Perform Dog Check Service 
    * @param none.
    */ public native int DogCheck();   /**
    * Perform Dog Convert Service 
    * @param none.
    */ public native int DogConvert();   /**
            * Perform Dog Write Service 
    * @param none.
    */ public native int WriteDog();

    /**
            * Perform Dog Read Service 
    * @param none.
    */ public native int ReadDog();

    /**
            * Perform Dog DisableShare Service 
    * @param none.
    */ public native int  DisableShare(); /**
            * Perform Dog GetCurrentNo Service 
    * @param none.
    */ public native int  GetCurrentNo();

    /**
     * Static initializer 
     */    static 
        {
            try 
            {
                    System.loadLibrary("DOGJava"); 
            }
            catch( UnsatisfiedLinkError e )
            {
                System.err.println("Can't find library DOGJava.DLL"); 
                System.exit( -1 );
            }
         }
    }      第三个文件:DOGGSMH.java
    package p1.p1;public class DOGGSMH extends GSDOG
    { /**
     *Checks whether a Dog is plugged in the parallel ports
     *return 0 if success
     *
     */
    public boolean CallDogCheck()
    throws DOGException
    {
    int retCode; if((retCode=DogCheck())!=0)
    return false;
    else
    return true;
    }
    /**
     *send a byte array to Dog and convert it to an int
     *return 0 if success
     *
     */ public void CallDogConvert()
    throws DOGException
    {
    int retCode; if((retCode=DogConvert())!=0)
    throw new DOGException(retCode);
    else
    {
    System.out.println("Dog Convert is OK!" + "  Convert result is: "+ DogResult);
    }
    } /**
     *write a byte array to Dog memory 
     *return 0 if success
     *
     */ public void CallWriteDog()
    throws DOGException
    {
    int retCode; if((retCode=WriteDog())!=0)
    throw new DOGException(retCode);
    else
    {
    System.out.println("WriteDog is OK!");
    }
    }
    /**
     *read Dog memory
     *return 0 if success
     *
     */ public void CallReadDog()
    throws DOGException
    {
    int retCode;
    char[] toPrint;
    int i;
                    int serialno=0;
                    
    toPrint=new char[DogBytes];
                    
    if((retCode=ReadDog())!=0)
    throw new DOGException(retCode);
    else

      System.out.println("Dog Read is OK!");
      System.out.print("Dog Read result ");
      for(i=0;i<DogBytes;i++)
      {
    toPrint[i]=(char)DogData[i];

    System.out.print(toPrint[i]);
      }
      System.out.println("");
    } } /**
     *get the current no
     *return 0 if success
     *
     */
    public void CallGetCurrentNo()
    throws DOGException
    {
    int retCode; if((retCode=GetCurrentNo())!=0)
    throw new DOGException(retCode);
    else
    {
    System.out.println("GetCurrentNo is OK!" + "  current no is: " + DogResult);
    }
    } /**
     * disable share
     *return 0 if success
     *
     */
    public void CallDisableShare()
    throws DOGException
    {
    int retCode; if((retCode=DisableShare())!=0)
    throw new DOGException(retCode);
    else
    System.out.println("DisableShare is OK!");
    }}第四个文件:DogDemo.java(JSP调用这个)
    package p1;import p1.p1.*;public class DogDemo 
    {
    public boolean checkdog()
    {
    int retCode,i;

    //System.out.println( "Microdog Sample Program for Java." );
    //System.out.println( "Copyright (C) 2002 Rainbow China Co.,Ltd. All Rigths Reserved." );
           // System.out.println( "Implemented by JDK 1.2 release\n" );


    DOGGSMH sample = new DOGGSMH();
    sample.DogCascade = 0;
    sample.DogPassword=0; sample.DogData = new byte[200];
    for (i=0;i<200;i++)
    sample.DogData[i]=(byte)(i+48);

    try 
    {
    sample.CallDisableShare();
    }
    catch(DOGException e)
    {
    //System.err.println( "  DisableShare Error: " + e.Error);
    return false;



    try 
    {
    sample.CallDogCheck();
    }
    catch(DOGException e)
    {
    //System.err.println( "  Dog Check Error: " + e.Error);
    return false;
    }  return true;
    }

    /* public static void main(String[] args)  {  DogDemo a = new DogDemo();
    if(!a.checkdog())
    {
    System.out.println("The Call is fail!");
    }
    else
    System.out.println("The Call is ok!");
    } */} JSP:
    <jsp:useBean id="dog" scope="page" class="p1.DogDemo" />
    <%
    out.println("The Counter is : " + "<BR>");
    if(dog.checkdog()){
    out.println("The Call is ok" + "<BR>");
    }
    else
    {
    out.println("The call is fail!");
    }
    %>然后就是上面的错!
      

  3.   

    多写了一个p1
    java文件都在package p1中
      

  4.   

    bean 没有import 进来,在试一试
      

  5.   

    加了这个了<%@ page language="java" import="p1.DogDemo" %>在<jsp:useBean之前还不行。
      

  6.   

    static 
        {
            try 
            {
                    System.loadLibrary("DOGJava"); 
            }
            catch( UnsatisfiedLinkError e )
            {
                System.err.println("Can't find library DOGJava.DLL"); 
                System.exit( -1 );
            }
         }
    这段代码有问题,servlet中自己的代码不能退出System.exit( -1 );这样会造成web server退出。
    你上面提的问题没有问题,不知道你那里怎么会错
      

  7.   

    我原来碰到过一次这样的问题,就是两个JSP页面都定义了一个名字为dog的javabean,实际上它们是不同的类,例如你在第一个页面定义:<jsp:useBean id="dog" scope="page" class="p1.DogDemo1" />另外一个页面定义:
    <jsp:useBean id="dog" scope="page" class="p1.DogDemo" />
    就会产生错误。
      

  8.   

    Bean里边可以加入main。
    我建议你把jsp放到Jbuilder中检查一下,Jbuilder或许能帮你发现错误。