Japplet in jsp

hi all
i cant understand what wrong i m doing....i m annoyed very much
my jsp page is in /UASEProject/Webcontent directory and applet class is in /UASEProject/Webcontent/registration directory and also its java file. jsp page is running successfully with the url htttp://localhost:9080/UASEProject/myjsp.jsp.but when i tried to access an japplet with the context specified below then in jsp at inserting area a red cross is displayed. the browser showing a message "applet not initited" and when i clicked in that red cross then the message was "applet loading failed".
i m using rational application developer and it uses the server 'IBM web sphere application server v6.1'
please.....check this out and give ur suggession.
this is my jsp page
<table>
   <tr>
      <td>
                 <jsp:plugin type="applet" code="NewJApplet.class" codebase="registration"
               width="600" height="300">
     <jsp:fallback>Could not load applet...</jsp:fallback>
               </jsp:plugin>
    </td>
  </tr>
</table>i have tried with this also
<table>
   <tr>
      <td>
                 <applet code="NewJApplet.class" codebase="registration"
               width="600" height="300">
               </applet>
    </td>
  </tr>
</table>

First, you shouldn't be calling paint with what you get from getGraphics(). You should update your state and call repaint() on the applet.
You should probably load the images with the media tracker in the init() method anyway and ditch that thread thing. Unless they're really large images which you want to load asynchronously.
Second, your onload init() thing in JS is kinda pointless. You might do that to have the applet trigger that method, but not onload, as that's right away. The browser shouldn't wait for the applet to start. to call onload. Anyway, an applet in a hidden DIV might not load at all anyway, in some browsers.

Similar Messages

  • Calling JApplet from jsp

    Hi,
    Can any one tell me how to call JApplet from JSP? I am using <jsp:plugin>
    tag but it is not working.

    use the jsp:plugin tag like this in your jsp page..
    <jsp:plugin  type="applet"
         code="appletclsname.class"
         codebase="ourapplets"
         jreversion="1.5"
         width="400px"
         height="200px">
    </jsp:plugin>

  • Passing value from JApplet to Jsp page

    Hello,
    How can i pass a value that is entered in a JTextArea in a JApplet and fetch the entered value from JTextArea and display it in a JSP page.
    It would be kindful if someone could help me with this problem.
    Regards
    Sanam

    hello,
    Thanks for ur reply,
    Sorry to say that i did not understand where to implement ur code in my code.
    Below is my code could u plz tell me where do i put in ur code.
    My code works fine u can compile it.
    javac *.java;
    appletviewer BIA.java
    Can u plz tell the JSP code.
    It would be very kindful if u could please help me.
    Thank you
    //**************** BIA.java***********
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    <applet code = "BIA" width = 500 height = 500>
    </applet>
    public class BIA extends JApplet
         public static Container cp;
         public BIAP panel;     
         public TB action;
         public void init()
              panel = new BIAP();
              action = new TB(panel);
              action.setLayout(new GridLayout(2,2));     
              cp = getContentPane();
              cp.setLayout(new BorderLayout());
              cp.add(action, "North");
              cp.add(new JScrollPane(panel));
              repaint();
    //******************* BIAP.java*************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    class BIAP extends JPanel
         public BIA bia;
         public BufferedImage image;
         public double scale, scaleInc;
         public JTextArea jt;
         public BIAP()
              loadImage();
              setBackground(Color.white);
              scale = 1.0;
              scaleInc = 0.01;
              setLayout(null);
              jt = new JTextArea("Welcome");
              jt.setBounds(0,0, 90,30);
              add(jt);     
              repaint();
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
                   Graphics2D g2 = (Graphics2D)g;
              g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BICUBIC);
              int w = getWidth();
              int h = getHeight();
              int imageWidth = image.getWidth();
              int imageHeight = image.getHeight();
              int x = (w - imageWidth)/2;
              int y = (h - imageHeight)/2;
              g2.drawImage(image, x, y, this);
         private void loadImage()
              String fileName = "Terragen___Losing_Grip_by_Blackheart6004.jpg";
              try
              URL url = getClass().getResource(fileName);
              System.out.println(url);
              image = ImageIO.read(url);
              catch(MalformedURLException mue)
              System.out.println("url: " + mue.getMessage());
              catch(IOException ioe)
              System.out.println("read: " + ioe.getMessage());
         public Dimension getPreferredSize()
              Dimension d = new Dimension();
              d.width = (int)(scale * image.getWidth());
              d.height = (int)(scale * image.getHeight());
              return d;
         //method used for Zoom Operation
         public void setScale (int inc)
              scale += inc * scaleInc;
              revalidate();
              repaint();
    //************************** TB*********************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class TB extends JPanel
         BIAP panel;
         JButton save = new JButton("Save");
         public TB(BIAP biap)
              panel = biap;
              ActionListener sa = new ActionListener()
                   public void actionPerformed(ActionEvent e)          
                        JButton button = (JButton)e.getSource();
                        if(button == save)
                             //panel.fileSave();
              save.addActionListener(sa);
              add(save);
    }

  • Why JApplet and JSP cannot connect to MySQL

    When i use applet connect to MySQL, it show that no suitable driver.
    My program is
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class fuck extends JApplet implements ActionListener
    private JButton bb = new JButton("update");
    private JTextArea aa = new JTextArea(1,7);
    private JTextArea ss = new JTextArea(1,7);
    private JPanel pp = new JPanel();
    public fuck()
    Container c=getContentPane();
    pp.add(aa);
    pp.add(ss);
    pp.add(bb);
    c.add(pp);
    bb.addActionListener(this);
    public void actionPerformed(ActionEvent ee)
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    catch(ClassNotFoundException e)
    System.out.println(e.getMessage());
    try
    Connection con =
    DriverManager.getConnection("jdbc:mysql://localhost/air","root","");
    Statement st = con.createStatement();
    //PreparedStatement pst = con.prepareStatement(
    // "update aa set condition=? where temp=?");
    //pst.setInt(1,3);
    //pst.setString(2,"hg");
    //pst.executeUpdate();
    ResultSet rs=
    st.executeQuery("select * from aa");
    while (rs.next())
    aa.setText(rs.getString("temp"));
    ss.setText(rs.getString("condition"));
    st.close();
    con.close();
    catch(SQLException ex)
    System.err.println("SQLException:"+ex.getMessage());
    If I using JSP, it also have some condition

    Clearly it is in the classpath, otherwise the error would have been "Class not found". But here's a quote from the documentation for the driver, the part that explains how to make a connection:// The newInstance() call is a work around for some
    // broken Java implementations
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();The "broken Java implementations" it refers to are certain JVMs that run applets in browsers...

  • Japplet jar file

    hi friends.....
    i have created an java project in which an japplet file is added. i searched allover in this folder but barring japplet class file and javafile there is not any other file created after running this japplet.
    actually my quary is how can i find japplet jar file and is there any need of it for running japplet in jsp??
    one mere question what is the role of html converter for running japplet in jsp and how can i find it??although i have read it from google but still not able to understand.
    any help is much appreciated

    URL url=myApplet.class.getResource("images/icons/up.gif");was giving null URL
    Works for me (jre 1.4+), see link shown below:
    http://home.attbi.com/~aokabc/ABC/Index.htm
    Just curious, which jre are you using?
    but
    myApplet.class.getClassLoader().getResource("images/icons/up.gif");
    works fineSo, problem solved?
    ;o)
    V.V.

  • Tomcat can't detect the class file of the JApplet.

    Hi,
    I am relatively new in the applet field. I am trying to invoke an JApplet through JSP.
    Problem is that i have to package the JApplet class files as it has to access other packages. also the JSP with the embedded JApplet exists in a different folder from the JApplet class files.
    I am getting the class not found exception.
    Context Path: http://localhost:8080/sncdatagate
    folder structure as follows.
    sncdatagate\jsp\myApplet.jsp
    sncdatagate\WEB-INF\classes\datagate\ui\myApplet.class
    package for myApplet.java : datagate.ui
    The JSP code is as follows :-
    <jsp:plugin
    type="applet"
    code="datagate.ui.myApplet"
    codebase="/sncdatagate/"
    width ="700"
    height="400"
    iepluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
    nspluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
    jreversion="1.3.1_01">
         <jsp:params>
                             <jsp:param name = "encodedString" value="<%=encodedString%>"/>
              </jsp:params>
    </jsp:plugin>
    The error on Java console is as follows:-
    load: class datagate.ui.myApplet not found.
    java.lang.ClassNotFoundException: java.io.FileNotFoundException: File not found: http://localhost:8080/sncdatagate/datagate/ui/myApplet.class
         at sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown Source)
         at java.net.HttpURLConnection.getResponseCode(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Kind help!
    Would greatly appreciate any suggestions.
    Thank You.
    regards,
    Priya

    The WEB-INF\classes\ folder is meant for servlets and the files insides are accessed thru the "servlet/" folder. To run applets, place them outside of the web-inf folder together with your jsp files.
    If your applet has a package, remember to create appropriate folders for it. Eg.
    sncdatagate\jsp\myApplet.jsp
    sncdatagate\datagate\ui\myApplet.class
    <applet
    code="datagate.ui.myApplet"
    codebase="/sncdatagate/" ...

  • Object tag problem

    hi all......
    i unable to identify where sould i make changes to use java plug in from installed jre 1.6 in my system??
    i m using jdk1.6.0,IE7.0,xp sp2
    please mark the line and suggest me!!
    below is my jsp page
          <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
        width="200" height="200" align="baseline"
        codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
        <PARAM NAME="code" VALUE="myclass.class">
        <PARAM NAME="codebase" VALUE="registration/">
        <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2.2">
        <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz">
        <PARAM NAME="scriptable" VALUE="true">
            No JDK 1.2 support for APPLET!!
    </OBJECT>i want to run japplet in jsp. please tell me also whether this tag is relevant or should i use other(please specify tag with its full code).
    any help would be much appreciated.

    I finally figured out how to get the object tag to work. The html fragment below is a typical solution:
         <object codetype="application/java" classid="java:MyApplet.class" width="250" height="400" style="vertical-align: baseline;">     <!-- Note: to force use of sun's Java Plugin, will need to change the classid; see http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html -->
                   <!-- Specify the Applet class to use: -->
              <param name="code" value="MyApplet.class">     <!-- for now, this is a duplicate of the info already in the above classid, but it will differ if use sun plugin -->
              <param name="codebase" value="./">
              <param name="archive" value="./appletResources.jar">
                   <!-- Specify archive caching (see http://java.sun.com/j2se/1.3/docs/guide/misc/appletcaching.html): -->
              <param name="cache_option" value="No">
              <param name="cache_archive" value="./animationResources.jar">
                   <!-- Specify below any optional param elements any further properties specific to MyApplet: -->
              <param name="someParameter" value="someValue">
                   <!-- Text to display if Java not supported: -->
              A Java applet should be here, but either your browser does not support Java, Java has been disabled, or an error occurred.
         </object>The html fragment above validates against the strict html 4.01 DTD.
    It has been sucessfully tested against Mozilla 1.1, IE 6 sp1, and Sun's appletviewer program.
    It will fail, however, in the horrid Netscrape 4.x series of browsers.

  • Cant understand

    hi all......
    i m trying to embed an japplet in jsp but when i tried to run this jsp on server then there is a messege..
          click here to activate and use this activex control         although it is not a part of java code even though i wrote it here.
    if u awared of this then please let me know also about it and what should my next step??
    thanks
    angilna

    I've no experience with applets but as far as I can tell, this particular message is specific to your browser. Perhaps some plugin needs to be enabled first as a security precaution. I used to see this for Flash animations on some sites.
    What happens when you click? Does the applet work then?
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • Code does not make any effect:need help

    hello friends,
    now i am going to describe the problem i am phasing
    actually i have embedded japplets in a jsp page(appletjsp) and want to communicate japplets indeed jsp to a servlet in the diffrent derectory but in same context root.
    moreover, i have written code at applet and servlet side both. actually there is a next button in one of japplets(embedded in appletjsp) and i have written the code(for servlet communication) inside button's mouse clicked event. and at servlet side, as usual i have got an inputstream from request and want to forward this request(after getting request dispatcher) to another jsp page(proposing to display this jsp page after clicking next button inside appletjsp ).
    now the problem that made me a bit confused is that when i click next button after running jsp page(containing japplets) then neither there is any error/exception at server/IE's sun java console nor any effect of code at servlet side.
    actually i am not sure that the servlet side code does not make any effect rather it is ony my assumption.
    although i am very new in java and as what i know, to send back response to client side, servlet class needs to be run at server side and probabbly for that there must be a sepreat request from client's applet to server(please dont flame me if i am wrong).
    so please tell  me how can i get running another jsp page running(to which i trying to get request dispatcher inside servlet) after clicking next button?
    applet code
            try{      
            String[] data    ={"santosh","kumar","tripathi"};        
            String strwp ="/UASProject/RegistrationData";              
            URL jspURL = new URL(getCodeBase(),strwp);             
            System.out.println(jspURL);
            URLConnection jspCon = jspURL.openConnection();               
            jspCon.setUseCaches(false);
            jspCon.setDoOutput(true);
            jspCon.setDoInput(false); 
            jspCon.setDefaultUseCaches(false);   
            jspCon.setRequestProperty("Content-Type", "application/x-java-serialized-object");      
           BufferedOutputStream bos=new BufferedOutputStream( jspCon.getOutputStream());
            ObjectOutputStream oboutStream = new ObjectOutputStream(bos);             
            oboutStream.writeObject(data);         
            oboutStream.flush();        
            bos.close();
            oboutStream.close();        
         //  getAppletContext().showDocument(new URL(getCodeBase().getProtocol(),getCodeBase().getHost(),getCodeBase().getPort(),"/UASProject/faces/Editpage.jsp"),"_self");        
         }catch(Exception e) 
           {System.out.println(e);}servlet code
             try { 
                    //    response.setContentType("application/x-java-serialized-object");
                         BufferedInputStream bis=new BufferedInputStream( request.getInputStream());
                        ObjectInputStream inputFromjsp = new ObjectInputStream(bis);                                      
                        reg_data = (String[])inputFromjsp.readObject();                             
                        out.println(reg_data[1]);
                        bis.close();
                        inputFromjsp.close();    
                       HttpSession session =request.getSession(true);
                      session.setAttribute("first_name",reg_data[0]);
                        getServletContext().getRequestDispatcher("http://localhost:8084//UASProject/faces/Editpage.jsp").forward(request,response);
                   } catch (Exception e) {e.printStackTrace();}    although this topic has been made too long, even then please fix my problem.
    thanks

    When you formatted the system you erased everything on the harddrive, obviously, and so its just a matter of putting back the Apps and data that you want from your Backup that you made, BEFORE reformatting the harddrive.  You did make a backup, didn't you??   Your Time machine or other external harddrive backup can be used with Migration Assistant to return the iLife Apps to the iMac.  If he indeed purchased the iLife Apps from the App Store, then you would need to use His Apple ID account to redownload them; not yours.
    Oh, and to answer your other question, no, iLife is not a part of any version of OSX itself.
    Hope this helps
    Message was edited by: Radiation Mac

  • How can i get the value of an jcombobox in a japplet into my html/jsp page

    hii
    i hav a japplet which contains an editable jcombobox
    which i have embedded into my jsp page .Now i want to get the value of jcombobox in my japplet into a taxt box in my .jsp page which will change as the value of jcombobox changes .Now in doing this i guess i will have to writer some public event in my japplet which will return the value into my web page .
    Now in doing so my first problem is to refer the japplet from my jsp page .In case of ordinary applets which does nt use swing i hav used id attribute in my applet tag and the document recognize it as its object just like any other html controls.
    but here although my japplet is running after installing plug -in the document is not regognizing the japplet .I hav tried with both <object > and <applet> tag .
    The name attribute in object tag is only changing the name of the class into that name given in the name attribute in the browser .
    I need to solve this out .Any help will be greatly appreciated

    Please help me .Its very urgent

  • Passing value from JSP to JApplet

    Hello,
    I am stuck up with a problem, can anyone please tell me how do i pass a value from a JSP page
    to a JApplet,
    and the parameter passed through JSP should be displaed in the JTextArea.
    It would be kindful if any of you could help.
    Thanks
    Sanam

    hello,
    thanks for reply.
    I know how to pass parameters from html,
    I want to pass values from jsp page,
    and i dono how to do it, may be we cann pass values through url connection but i dono how.
    if anone knows plz help me in solving this.
    i hvae posted my applet code.
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.JToolBar;
    import javax.swing.JButton;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JPanel;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    <applet code = "DocApplet" width = 500 height =5000>
    </applet>
    public class DocApplet extends JApplet
         private JPanel jp;
         private Container cp;
         private JTextArea jt;
         private JToolBar tb;     
         private JScrollPane sp;
         private String annotation;
         private String url;
         private Connection con;
         private Statement stmt;
         public void init()
              jp = new JPanel();
              cp = getContentPane();
              jt = new JTextArea();
              tb = new JToolBar();
              sp = new JScrollPane(jt);
              repaint();
         public void start()
              jp.setLayout(new BorderLayout());
              jp.add(tb, BorderLayout.NORTH);
              jp.add(sp, BorderLayout.CENTER);
              jt.setBackground(Color.BLACK);
              jt.setForeground(Color.WHITE);
              setContentPane(jp);
              addButtons(tb);
              repaint();
         public void run()
              repaint();
         public void paint()
         private void addButtons(JToolBar tb)
              JButton button = null;
              button = new JButton("Save");
              button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent e)
              tb.add(button);
    }

  • Japplet program Or chart calling in jsp

    hi
    i am new to java & i have crated a chart program in Japplet
    that program i want to run in jsp (NetBeans 5.50)

    hi
    i am new to java & i have crated a chart program
    in Japplet
    that program i want to run in jsp (NetBeans 5.50)
    plz replay me soonnnnnnn

  • JApplet JDBC Bridge on jsp?

    Using the JSP JDBC as the JApplet JDBC, is this possible?
    I was planning to use the .jsp JDBC to the JDBC of the JApplet inside that .jsp.
    Or in other terms, could I run the JApplet on as a server instead of the client?
    I want to run the JApplet JDBC, but I couldn't because the JApplet runs as a client.
    Thanks,
    Cyril H.

    You can have make a servlet that's on the same server where the applet is coming from and then have the applet connect back to that server to ask the serverside to perform database access.

  • From JSP- Japplet and Back.

    I know it's possible from JSP -> Japplet by the use of throwing parameters .
    but how can the Japplet throw back data out for JSP to catch?

    Ron
    Here's what i wanted to do. I'm writing a Cinema ticket online booking system for my Group Project. I want to write an applet that can access the Oracle database indirectly thru JSP. (this is bcs I've tried JDBC and it's kind of slow and you need the user to install the JDBC package) . So the only way I came up with is thru Applet -> JSP -> ORACLE and back. Is this possible? or is there any way where i can decrease the d/l part for the JDBC package? (takes too long for 56k users).
    John

  • JApplet focus in JSP page

    I have an applet embeded in a JSP page. In this applet I have some text feilds for data entry. After the each data entry this field get validated . If the entered data is wrong then it popup a message using the JOptionPane.
    Now the problem. :- after message, I want to set back the focus to the respective fields. I had used setfocus(), grabfocus() etc..But nothing get worked.. Please advice ... tanx in advance...........
    Rgds
    Joe

    That's struts-specific. We're here in a JSP/JSTL forum.

Maybe you are looking for