Connecting Tech Pros Worldwide Help | Site Map

how 2 communicate applet and jsp?

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 10th, 2006, 08:35 AM
rajesh
Guest
 
Posts: n/a
Default how 2 communicate applet and jsp?


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.s etText("");tt2.setText
("");

}

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


}

}


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







*** Sent via Developersdex http://www.developersdex.com ***

  #2  
Old February 10th, 2006, 08:45 AM
VK
Guest
 
Posts: n/a
Default Re: how 2 communicate applet and jsp?


rajesh wrote:[color=blue]
> here is my coding can any one help me to communicate b\w applet and
> jsp,...[/color]

Please:

1. Open appleeet.jsp from server into your preferred browser.
2. View > Page Source
3. Select All > Copy > post in this thread

  #3  
Old February 10th, 2006, 08:55 AM
rajesh
Guest
 
Posts: n/a
Default Re: how 2 communicate applet and jsp?

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 ***
  #4  
Old February 10th, 2006, 08:55 AM
loyal_caper@easypeas.net
Guest
 
Posts: n/a
Default Re: how 2 communicate applet and jsp?

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.

  #5  
Old February 10th, 2006, 08:55 AM
VK
Guest
 
Posts: n/a
Default Re: how 2 communicate applet and jsp?


rajesh wrote:[color=blue]
> 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>[/color]

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>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.