how 2 communicate applet and jsp?

R

rajesh

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>
 
V

VK

rajesh said:
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
 
R

rajesh

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>
 
L

loyal_caper

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.
 
V

VK

rajesh said:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

revise my code 2
JTables 1

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top