CHECK THIS CODE.
/*
<applet code=3D"tkdt.class" width=3D400 height=3D400>
</applet>
*/
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
public class tkdt extends Applet implements ActionListener, Runnable {
Thread t1;
Panel pn1;
Button b1, b2, b3;
TextArea ta;
Label lb;
String hstnm, srvstr, srvstrsh, srvstrpt;
int prt;
URL url1;
int cnt; =
Vector vct;
java.awt.List lst;
ObjectInputStream ois;
public void init() {
this.setLayout(new BorderLayout());
pn1 =3D new Panel();
b1 =3D new Button("SHOW1");
b2 =3D new Button("INSERT");
b3 =3D new Button("CANCEL");
ta =3D new TextArea(10, 50);
lb =3D new Label("HOW R U");
hstnm =3D "localhost";
prt =3D 8080;
srvstr =3D ("http://"+hstnm+":"+prt+"/servlet/serv2app");
srvstrpt =3D "";
cnt =3D 1;
b1.addActionListener(this);
b2.addActionListener(this);
pn1.add(b1);
pn1.add(b2);
pn1.add(b3);
vct =3D new Vector();
this.add("North", pn1);
this.add("Center", ta);
this.add("South", lb);
try {
url1 =3D new URL(srvstr);
}catch(java.net.MalformedURLException me) {
ta.append("Error in URL excpt"+me);
}
}
public void start() {
t1 =3D new Thread(this);
}
public void stop() {
t1 =3D null;
}
public void run() {
try {
while(true) {
Thread.sleep(250);
repaint();
}
}catch(InterruptedException ie) {
System.out.println("ERROR in run-"+ie);
}
}
public void showlst() {
repaint();
ta.append("harami");
srvstrsh =3D
(srvstr+"?"+URLEncoder.encode("thelist")+"=3D"+URLEncoder.encode("allof")=
);
ta.setText("");
ta.append("url=3D"+srvstrsh);
vct.clear();
try {
url1 =3D new URL(srvstrsh);
URLConnection urlcon =3D url1.openConnection();
ois =3D new ObjectInputStream(urlcon.getInputStream());
vct =3D (Vector) ois.readObject();
ois.close();
for(int i=3D0; i<vct.size(); i++) {
ta.append((String)vct.elementAt(i)+"\n");
}
}catch(java.net.MalformedURLException me) {
System.out.println(me);
ta.append("Error in URL Mal-excpt"+me);
}catch(IOException me) {
System.out.println(me);
ta.append("Error in URL IO-excpt"+me);
}catch(ClassNotFoundException me) {
System.out.println(me);
ta.append("Error in URL IO-excpt"+me);
}
}
public void doins() {
}
public void actionPerformed(ActionEvent ae) {
System.out.println("in act lstnr");
cnt+=3D5;
if(ae.getSource() =3D=3D b1) {
System.out.println("b1 prss");
ta.append("b001 prss");
this.showlst();
}
if(ae.getSource() =3D=3D b2) {
ta.append("b2 prss");
System.out.println("b2 prss");
doins();
}
}
}
Regards,
Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-1031
-----Original Message-----
From: Falls, Travis D (CASD, IT) [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 08, 2002 11:40 AM
To: [EMAIL PROTECTED]
Subject: applet call a servlet
can someone explain to me how I can call a method in a servlet or just in a
class file that sites on a server from an applet?
Travis
This communication, including attachments, is for the exclusive use of
addressee and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, any use, copying,
disclosure, dissemination or distribution is strictly prohibited. If
you are not the intended recipient, please notify the sender
immediately by return email and delete this communication and destroy all
copies.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html