how 2 communicate applet and jsp?

Discussion in 'Javascript' started by rajesh, Feb 10, 2006.

  1. rajesh

    rajesh Guest

    here is my coding can any one help me to communicate b\w applet and
    jsp,...


    "appleeet.jsp"
    ------------
    <%@ page language="java" %>


    <jsp:plugin type="applet" code="sample2.class"
    codebase="/appleet/sample2.java" jreversion="1.2" width="160"
    height="150" >
    <jsp:fallback>
    Plugin tag OBJECT or EMBED not supported by browser.
    </jsp:fallback>
    </jsp:plugin>

    "sample2.java" is the java code
    -------------

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;

    public class sample2 extends JApplet implements ActionListener
    {
    JLabel l1,l2,l3,l4,l5;
    JTextField t1,t2,t3;
    JPasswordField tt1,tt2;
    JButton b1,b2,b3;
    JPanel p;
    Font f;

    public void init()
    {
    Container c=getContentPane();
    //c.setLayout(new FlowLayout(0));
    c.setBackground(Color.cyan);

    f=new Font("Monotype Corsiva",Font.BOLD,16);

    //creating panel
    p=new JPanel();
    p.setLayout(new GridLayout(7,2));
    p.setBackground(Color.green);
    // p.setFont(f);

    p.setLocation(200,200);

    //creating components
    l1=new JLabel("First name ");l1.setFont(f);
    l2=new JLabel("Last name ");l2.setFont(f);
    l3=new JLabel("Login id ");l3.setFont(f);
    l4=new JLabel("Password");l4.setFont(f);
    l5=new JLabel("Confirm password");l5.setFont(f);


    t1=new JTextField(10);
    t2=new JTextField(10);
    t3=new JTextField(10);

    tt1=new JPasswordField();
    tt2=new JPasswordField();

    b1=new JButton("Check");b1.addActionListener(this);
    b2=new JButton("clear");b2.addActionListener(this);
    b3=new JButton("Reset");b3.addActionListener(this);

    //adding components to panel
    p.add(l1);
    p.add(t1);
    p.add(l2);
    p.add(t2);
    p.add(l3);
    p.add(t3);
    p.add(l4);
    p.add(tt1);
    p.add(l5);
    p.add(tt2);
    p.add(b1);
    p.add(b2);
    p.add(b3);

    //adding panel to container
    c.add(p);
    }
    public void actionPerformed(ActionEvent e)
    {

    String ss1="";
    String s=tt1.getText();
    String s1=tt2.getText();


    a: if(e.getSource()==b1)
    {

    if(t1.getText().equals(ss1))
    {
    JOptionPane.showMessageDialog(null,"Please
    enter the first name", null, JOptionPane.ERROR_MESSAGE );
    t1.requestFocus(true);
    break a;
    }

    if(t2.getText().equals(ss1))
    {
    JOptionPane.showMessageDialog(null,"Please
    enter the last name", null, JOptionPane.ERROR_MESSAGE );
    t2.requestFocus(true);
    break a;
    }

    if(t3.getText().equals(ss1))
    {
    JOptionPane.showMessageDialog(null,"Please
    enter the Login id", null, JOptionPane.ERROR_MESSAGE );
    t3.requestFocus(true);
    break a;
    }

    if(tt1.getText().equals(ss1))
    {
    JOptionPane.showMessageDialog(null,"Please
    enter the password", null, JOptionPane.ERROR_MESSAGE );
    tt1.requestFocus(true);
    break a;
    }

    if(tt2.getText().equals(ss1))
    {
    JOptionPane.showMessageDialog(null,"Please
    enter the confirm password", null, JOptionPane.ERROR_MESSAGE );
    tt2.requestFocus(true);
    break a;
    }

    else {
    if(s.equals(s1))
    {

    JOptionPane.showMessageDialog(null,"The entered
    password is correct"," Verification",
    JOptionPane.INFORMATION_MESSAGE );
    }

    else
    {

    JOptionPane.showMessageDialog(null,"Please type the
    password correctly"," Verification", JOptionPane.WARNING_MESSAGE );
    tt2.setText("");
    }
    }
    }



    if(e.getSource()==b3)
    {

    t1.setText("");t2.setText("");t3.setText("");tt1.setText("");tt2.setText
    ("");

    }

    if(e.getSource()==b2)
    {
    tt2.setText("");
    }


    }

    }


    //<applet code=sample2 height=200 width=200></applet>







    *** Sent via Developersdex http://www.developersdex.com ***
    rajesh, Feb 10, 2006
    #1
    1. Advertising

  2. rajesh

    VK Guest

    rajesh wrote:
    > here is my coding can any one help me to communicate b\w applet and
    > jsp,...


    Please:

    1. Open appleeet.jsp from server into your preferred browser.
    2. View > Page Source
    3. Select All > Copy > post in this thread
    VK, Feb 10, 2006
    #2
    1. Advertising

  3. rajesh

    rajesh Guest

    communication b\w applet and JSP

    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="160"
    height="150"
    codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.c
    ab#Version=1,2,2,0">
    <PARAM name="java_code" value="sample2.class">
    <PARAM name="java_codebase" value="/appleet/sample2.java">
    <PARAM name="type" value="application/x-java-applet;version=1.2">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.2" width="160"
    height="150" pluginspage="http://java.sun.com/products/plugin/"
    java_code="sample2.class" java_codebase="/appleet/sample2.java" >
    <NOEMBED>
    </COMMENT>
    Plugin tag OBJECT or EMBED not supported by browser.

    </NOEMBED></EMBED>
    </OBJECT>

    *** Sent via Developersdex http://www.developersdex.com ***
    rajesh, Feb 10, 2006
    #3
  4. rajesh

    Guest

    What do you mean by "communicate b\w applet and jsp"--you want to
    establish client/server communication? Then probably the easiest/best
    way to do it is to open a socket back to the server. If you're talking
    about communication between your applet and javascript (client/client
    communication), then you need to check out "live-connect"
    possibilities.

    Walter

    ----
    Walter Gildersleeve
    Freiburg, Germany

    ______________________________________________________
    http://linkfrog.net
    URL Shortening
    Free and easy, small and green.
    , Feb 10, 2006
    #4
  5. rajesh

    VK Guest

    rajesh wrote:
    > communication b\w applet and JSP
    >
    > <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="160"
    > height="150"
    > codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.c
    > ab#Version=1,2,2,0">
    > <PARAM name="java_code" value="sample2.class">
    > <PARAM name="java_codebase" value="/appleet/sample2.java">
    > <PARAM name="type" value="application/x-java-applet;version=1.2">
    > <COMMENT>
    > <EMBED type="application/x-java-applet;version=1.2" width="160"
    > height="150" pluginspage="http://java.sun.com/products/plugin/"
    > java_code="sample2.class" java_codebase="/appleet/sample2.java" >
    > <NOEMBED>
    > </COMMENT>
    > Plugin tag OBJECT or EMBED not supported by browser.
    >
    > </NOEMBED></EMBED>
    > </OBJECT>


    Sorry, it's not a page - it's a part of page. Where is the page itself
    with JavaScript where your applet is located and you want to
    communicate with?

    Or you mean applet <> server-side communication? In such case it has
    nothing to do with JavaScript (which is not Java). Try
    <comp.lang.java.help>
    VK, Feb 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Blah Blah
    Replies:
    0
    Views:
    1,421
    Blah Blah
    Aug 13, 2003
  2. Snyke
    Replies:
    4
    Views:
    542
    Snyke
    Nov 3, 2005
  3. Replies:
    0
    Views:
    4,338
  4. Mahesh Acharya
    Replies:
    0
    Views:
    386
    Mahesh Acharya
    Sep 29, 2008
  5. rajesh

    communicate b\w swing and JSP

    rajesh, Feb 16, 2006, in forum: Javascript
    Replies:
    2
    Views:
    119
    Thomas 'PointedEars' Lahn
    Feb 17, 2006
Loading...

Share This Page