Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default how to Import my Java Class in Jsp Page

    hello.
    i have a java class by name ShowClass that have a static method by name ShowAll.
    i will import this Class in jsp page by <%@page import=" %> but the netbeans ide cannot find my class.
    please see picture.
    thanks.


  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    i create a web dynamic project in eclipse.
    my web page is in web pages/CDStore2 and my class is in source packages/CDSClass.
    i upload the pic of those. please see this pic.
    thanks.

    Image Hosting Free

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    Shouldn't that import have "CDSClass/ShowClass" in it?

  6. #6
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Shouldn't that import have "CDSClass/ShowClass" in it?
    why shuldn't?
    i need this class. but cann't import this.

    Can't you use the complete package path, you are in two different packages?
    ShowClass is in CDSClass package in "source Packages" folder. but the jsp file is in "CDStore2" Folder in "web Pages" Folder.

    you can see it in pic.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    You currently have import="".
    Surely that should be import="CDSClass.ShowClass"?
    (Sorry, stuck in "/" before, when it should have been ".").

  8. #8
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    i get this Error:

    cann't find symbol
    symbol : class ShowClass
    location : package CDSClass

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    Have you actually compiled the class succesffully?

  10. #10
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    no.
    when i run this project, netbeans compiled all class and servlet.

    you can have access to a class after compile your project.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    "i create a web dynamic project in eclipse."
    "netbeans compiled all class and servlet."

    Which is it? Netbeans or Eclipse?

  12. #12
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    verry sorry.
    i have wrong in type.
    i use netbeans.
    i create a web dynamic project in netbeans.
    excuseme

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  14. #14
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    can you create a web dynamic in nebtneas with a simple class and a jsp file. then upload for me.
    thanks.

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,120
    Rep Power
    20

    Default

    How about posting the class?

  16. #16
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    i will have a sample.
    the content of class is not important;
    for example:
    a class that can generate random number. and a jsp file that was imported this class.

  17. #17
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by pos View Post
    i will have a sample.
    the content of class is not important;
    for example:
    a class that can generate random number. and a jsp file that was imported this class.
    It could be. That's why we ask your code here to look at it.

  18. #18
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Default

    please get it from follow link:
    2shared - download Learning.zip

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  20. #20
    pos
    pos is offline Member
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

Page 1 of 2 12 LastLast

Similar Threads

  1. can't import my own class
    By Splat in forum New To Java
    Replies: 5
    Last Post: 10-13-2009, 05:53 AM
  2. How do I call a class in jsp page
    By Greg in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 09-20-2009, 11:27 PM
  3. Replies: 0
    Last Post: 08-10-2009, 02:25 PM
  4. Replies: 4
    Last Post: 12-29-2008, 03:20 PM
  5. import java.util ????
    By kris09 in forum New To Java
    Replies: 3
    Last Post: 08-11-2008, 01:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •