Importing in jsp and java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pjerald
    New Member
    • Oct 2007
    • 77

    Importing in jsp and java

    I have two classes in two different packages.
    MyClass is in mypackage and YourClass in yourpackage.
    I imported MyClass in YourClass.
    For example,

    import mypackage.MyCla ss;

    and MyClass has a static variable(Class variable) named myStatic.

    and i used it some thing like

    someVarible = myStatic;

    this compiles good.

    But i did the same thin in a jsp file. There it wont compiled.

    Then i changed my code as,

    someVariable = MyClass.myStati c;

    Now it compiles successfully.


    Why it happens like this ?

    Am I wrong ?

    Thanks,
    P.Jerald
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by pjerald
    I have two classes in two different packages.
    MyClass is in mypackage and YourClass in yourpackage.
    I imported MyClass in YourClass.
    For example,

    import mypackage.MyCla ss;

    and MyClass has a static variable(Class variable) named myStatic.

    and i used it some thing like

    someVarible = myStatic;

    this compiles good.

    But i did the same thin in a jsp file. There it wont compiled.

    Then i changed my code as,

    someVariable = MyClass.myStati c;

    Now it compiles successfully.


    Why it happens like this ?

    Am I wrong ?

    Thanks,
    P.Jerald
    someVarible = myStatic; is legal only inside the class where the myStatic variable is defined. It won't work in any other class (e.g in a JSP)

    Comment

    • pjerald
      New Member
      • Oct 2007
      • 77

      #3
      Originally posted by r035198x
      someVarible = myStatic; is legal only inside the class where the myStatic variable is defined. It won't work in any other class (e.g in a JSP)

      Thanks,
      r035198x

      I got it.

      Comment

      Working...