Results 1 to 7 of 7
  1. #1
    ITMaster is offline Member
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default load classes to jsp page

    Hello All:

    This is my first thread in this forum and i hope to find the answer for my question.

    I have a code consistes of one class containing many sub-classes:

    public class TstClass
    {
    public class tst1
    {..}

    public class tst2
    {..}

    }

    and i want to call one of these classes in jsp page, how could this be done?

    I'm using Tomcat 6.0 amd JDK 1.6

    Thank you in advance to any one would help me in this issue :)

  2. #2
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    6

    Default

    jsp pages talk to beans. Its not clear if your classes are proper beans.

    Do you get the proper Tomcat hello page?

  3. #3
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    It is done while using Beans
    Java Code:
    <HTML>   
    <HEAD><TITLE>TstClass</TITLE></HEAD>  
    <BODY>
    
    <%@ page language="Java" %>  
    
    <jsp:useBean id="test" scope="request" class="TstClass" />
    
    <jsp:setProperty name="test" property="*" />
    
    <%=test.<your method in the TestClass>%>
    
     
    </body>
    
    </HTML>

  4. #4
    ITMaster is offline Member
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default

    Yes i got Tomcat hello page

  5. #5
    ITMaster is offline Member
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by serjant View Post
    It is done while using Beans
    Java Code:
    <HTML>   
    <HEAD><TITLE>TstClass</TITLE></HEAD>  
    <BODY>
    
    <%@ page language="Java" %>  
    
    <jsp:useBean id="test" scope="request" class="TstClass" />
    
    <jsp:setProperty name="test" property="*" />
    
    <%=test.<your method in the TestClass>%>
    
     
    </body>
    
    </HTML>
    I've tried this way and it doesn't work.

    what i need is to call the subclasses like "tst1, tst2" and creat objects from these subclasses in my jsp page like:

    tst1 obj = new tst1

    So what do you think?

    Thanx

  6. #6
    wolve634's Avatar
    wolve634 is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Smile

    Use scriptlet! and don't forget to import the class by :

    <%@ page import="package.class" %>

  7. #7
    wolve634's Avatar
    wolve634 is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default

    you can use scriptlet this way:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Scriptlet Demo</TITLE>
    </HEAD>
    <BODY>
    <%@ page import="package.myclass" %>
    <% myclass m=new myclass();
    out.system.out.println(m.sayHello());
    %>
    </BODY>
    </HTML>

Similar Threads

  1. Go back to previous page using session in JSP page
    By gopikarikati009 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-23-2011, 10:30 AM
  2. load external classes
    By gotenks05 in forum New To Java
    Replies: 17
    Last Post: 10-27-2008, 06:09 PM
  3. How to retain the checkbox selected after page load...?
    By prabhurangan in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-24-2008, 08:13 AM
  4. Add data to combobox in page load
    By hussainzim in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 05-15-2008, 12:57 PM
  5. how to load a servlet on index.jsp page...
    By sujithc34 in forum Java Servlet
    Replies: 1
    Last Post: 01-19-2008, 12:28 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
  •