Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2003

Tip: Looking for answers? Try searching our database.

My bean doesn't APPEAR on my JSP page!

Thread view: 
Kevin - 24 Aug 2003 02:35 GMT
Hi, All!

I have this simple bean (below), and i make the .class using JBuilder 7.0.

I tryed to insert this bean into my JSP page:

<%@ page contentType="text/html; charset=windows-1251" %>
<html>
<head>
<title>
Jsp1
</title>
</head>
<jsp:useBean id="bean0" scope="session" class="bean1.KivaHanTester" />
<jsp:setProperty name="bean0" property="*" />
<body>
<h1>
JBuilder Generated JSP
</h1>
</body>
</html>

BUT I CAN't see this bean, when i open my JSP (IExplorer + Apache).
May be i need to init this bean, like init() or show() i don't know.

Thanks.

SOURCE CODE:

package bean1;

import java.awt.*;

public class KivaHan extends Canvas {

 private String msg;
 private int width, height;

 public KivaHan () {
   this ("Coffee: 10 lira");
 }
 public KivaHan (String s) {
   this (s, 200, 200);
 }
 public KivaHan (String s, int width, int height) {
   msg = s;
   this.width = width;
   this.height = height;
   setForeground (Color.cyan);
   setFont (new Font ("Serif", Font.ITALIC, 24));
   setSize (getPreferredSize());
 }
 public void paint (Graphics g) {
   Dimension d = getSize();
   FontMetrics fm = g.getFontMetrics();
   int len = fm.stringWidth (msg);
   int x = Math.max (((d.width - len) / 2), 0);
   int y = d.height / 2;
   g.drawString (msg, x, y);
 }

 public Dimension getPreferredSize () {
   return new Dimension (width, height);
 }
}

package bean1;

public class KivaHanTester extends java.applet.Applet {
 public void init () {
   add (new KivaHan());
 }
}
G - 24 Aug 2003 10:30 GMT
I think you are trying to see an Applet (your 'bean' is an applet) in
your JSP, but this is not the aim of a bean in a JSP...

If you want your applet to run into your browser you must use the HTML
<applet> tag.

Remember: JSP is server side, applet is client side.

Regards.

> Hi, All!
>
[quoted text clipped - 69 lines]
>   }
> }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.