Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-07-2008, 03:11 PM
Member
 
Join Date: Nov 2008
Posts: 3
Rep Power: 0
ITMaster is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-08-2008, 06:08 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
jsp pages talk to beans. Its not clear if your classes are proper beans.

Do you get the proper Tomcat hello page?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-08-2008, 02:54 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
It is done while using Beans
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>
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-10-2008, 01:11 PM
Member
 
Join Date: Nov 2008
Posts: 3
Rep Power: 0
ITMaster is on a distinguished road
Default
Yes i got Tomcat hello page
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-10-2008, 01:18 PM
Member
 
Join Date: Nov 2008
Posts: 3
Rep Power: 0
ITMaster is on a distinguished road
Default
Originally Posted by serjant View Post
It is done while using Beans
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-10-2008, 03:29 PM
wolve634's Avatar
Member
 
Join Date: Oct 2008
Posts: 13
Rep Power: 0
wolve634 is on a distinguished road
Smile
Use scriptlet! and don't forget to import the class by :

<%@ page import="package.class" %>
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-10-2008, 03:33 PM
wolve634's Avatar
Member
 
Join Date: Oct 2008
Posts: 13
Rep Power: 0
wolve634 is on a distinguished road
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>
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
load external classes gotenks05 New To Java 17 10-27-2008 06:09 PM
How to retain the checkbox selected after page load...? prabhurangan JavaServer Pages (JSP) and JSTL 0 07-24-2008 08:13 AM
Add data to combobox in page load hussainzim JavaServer Pages (JSP) and JSTL 5 05-15-2008 12:57 PM
Go back to previous page using session in JSP page gopikarikati009 JavaServer Pages (JSP) and JSTL 0 04-27-2008 04:38 AM
how to load a servlet on index.jsp page... sujithc34 Java Servlet 1 01-19-2008 12:28 AM


All times are GMT +2. The time now is 04:26 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org