Hi friends,

    I am using java applet that will perform some operations. Now it is independent of jsp or html page. So,if i close an applet my html page remains active and Vice-Versa. What i want to do is embed an java Applet in html page itself. When i click on LOGIN BUTTON on login.htm page. That should invoke one method called PopUpAtt() which is in another jsp page(applet.jsp). In order to implement it,what i am doing is I just created one more jsp page called applet.jsp that contains my applet invoking code as like follows,(I have Given this code inside body tag) and I tried with one more way by using onload in body tag(<body onload="PopUpAtt()">). 

    But,Am getting ClassNotFoundException.. I need your help.. Please help me.. 

    This is my applet.jsp page.

    <%@ page language="java" pageEncoding="UTF-8"%>
    <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <%@ taglib  uri="http://www.springframework.org/tags" prefix="spring"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page import="java.io.*,java.util.*"%>
    <%@ page import="javax.servlet.*,java.text.*"%>
    <html>
    <head>
    <title>applet invocation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="content-language" content="en" />
    <meta http-equiv="Content-Language" content="EN" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <script type="text/javascript" language="javascript" src="<%=request.getContextPath() %>/js/deployJava.js"></script>
    <script type="text/javascript" language="javascript"
    src="<%=request.getContextPath()%>/scripts/deployJava.js"></script>
    <script>
    var applet;

    var coSignData;
    function PopUpAtt()
    {

            applet = document.applet;
            var formdata = document.getElementById("applicant_name").value;
            if(formdata == "")
            {
                alert("Please provide a name");
                return false;
            }
            else
            {
                applet.open(formdata, '', 'Submit()', 'Cancel()');
                return true;
            }
    }

        function Submit() 
        {

        var Data = applet.getGeneratedvalue();
        document.getElementById("data").value=Data;
        ack_generation();
        data(signData);

        }

    function Cancel() 
    {

        window.location.href="<%=request.getContextPath()%>/logout.htm";
    }


</script>
<div id="javaRequiredDiv"></div>
<script>
 var contextpath = "<%=request.getContextPath()%>/scripts/exampleApplet.jar";
        deployJava.do_initialize();
        if( deployJava.versionCheck("1.6+")==false ) {
            var java_message = 'Websigner requires JRE1.6 or higher. Please download it from <a href="www.java.sun.com">www.java.sun.com</a>. <br>Once Installation is done. Close the browser and relogin.';
            if (document.all)  {
                javaRequiredDiv.innerHTML=java_message;
            } else if (document.getElementById){
                rng = document.createRange();
                el = document.getElementById("javaRequiredDiv");
                rng.setStartBefore(el);
                htmlFrag = rng.createContextualFragment(java_message);
                while (el.hasChildNodes()) {
                    el.removeChild(el.lastChild);
                }
                el.appendChild(htmlFrag);
            }
        } else {
            var attributes = {
                    code :'packagename.Applet.class',               
                    archive : "<%=request.getContextPath()%>/scripts/exampleApplet.jar",
            width : 1,
            height : 1,
            name : 'applet'
        };
        var parameters = {
            MAYSCRIPT : 'true',
            scriptable : 'true',
            enableExpiryCheck : 'true',
            regexFilterIssuerName : ''
        };
        var version = '1.6';
        deployJava.runApplet(attributes, parameters, version);
    }
</script>
</head>
<body onload="PopUpAtt()">
</body>
</html>


And one more issue also.. i am working with spring application only.So,if i didnt write any controller for this jsp page,it is return me with page not found exception. If i write controller,then it will take me to the applet.jsp page,where i can see the preview of Applet with classnotfoundexception. can i invoke my applet without spring framework ah? I think,I can.. Because by simply clicking on LOGIN Button.it will invoke my applet. So,if i give give like as follows in login.htm page. 

<script>
$("#appletinvoke").click(function()
{
    $('#appletinvoke').load('<%= request.getContextPath() %>/jsp/applet.jsp'); 
 });
</script>

<input type="button" class="buttons" id="appletinvoke" value="Sign"  />

Is it correct?

Please help me.. 

Recommended Answers

All 7 Replies

what are you working in?
Java, or JavaScript?

anyway, this might help you out a bit.

Thanks for your reply... Am Working on javascript only,How could i call my applet??

applets are Java, not JavaScript.
maybe this will bring you closer to what you are looking for.

Myapplet is java. I am invoking my applet with java script as mentioned above..

Thanks for your reply.. As you said,i could able to do it.. Then What i will do for this code? Where i will have to put?
 <script>
    var applet;
    var coSignData;
    function PopUpAtt()
    {
            applet = document.applet;
            var formdata = document.getElementById("applicant_name").value;
            if(formdata == "")
            {
                alert("Please provide a name");
                return false;
            }
            else
            {
                applet.open(formdata, '', 'Submit()', 'Cancel()');
                return true;
            }
    }
        function Submit() 
        {
        var Data = applet.getGeneratedvalue();
        document.getElementById("data").value=Data;
        ack_generation();
        data(signData);
        }
    function Cancel() 
    {
        window.location.href="<%=request.getContextPath()%>/logout.htm";
    }
</script>

did you check the source code at that link?
just re-read the first part of your original post..
an applet written IN a jsp file? that makes .... no sense to me at all. the problem might be that you haven't created a correct applet.

No. What i wrote is that I have jsp page that contains code to invoke applet,not of applet creation..
Ya.. I just red your link and tried my applet is not working with jnlp file.. any other way to implement applet embedding friends..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.