Forums Register Login

HELP MAHA,,TONY,,FRANK!!!

+Pie Number of slices to send: Send
hi everyone !!
i have made a program to communicate from a applet to a servlet
applet code
------------
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
public class client15 extends Applet implements ActionListener
{String a="yvooo";
TextField t1;
Button b1;
public void init()
{
t1=new TextField(10);
b1=new Button("Send");
add(t1);
add(b1);
t1.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{String s=t1.getText();
try{
URL xx=new URL("http://parminder:9000/cool/book5");
a="helloasd";
repaint();
URLConnection c = xx.openConnection();
c.setDoInput(true);
c.setDoOutput(true);
c.setUseCaches (false);
c.setDefaultUseCaches (false);
c.setRequestProperty ("Content-Type", "application/octet-stream");
DataOutputStream d;
d = new DataOutputStream(c.getOutputStream());
d.writeBytes(s);
d.flush();
d.close();
/*DataInputStream d1 = new DataInputStream(c.getInputStream());
a=d1.readLine();
repaint();
d1.close();*/
}catch(Exception e)
{a=("fdf"+e);
repaint();}}
public void paint(Graphics g)
{g.drawString(a,10,50);
}}
this code is working fine.i am getting the connection to the
servlet as :helloasd" is printed after i click the "send" button.

SERVLET code
-------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class book5 extends HttpServlet
{public void doGet(HttpServletRequest r,
HttpServletResponse r1)
throws ServletException, IOException
{DataInputStream d1;
d1=new DataInputStream(r.getInputStream());
String b=d1.readLine();
PrintWriter pw=r1.getWriter();
pw.println(b);}
}

(I am invoking the applet from a html file from the Browser.)
now when i run this servlet from browser window it gives a
READ TIMED OUT exception.even if i use doPost or service
method problem remains the same.

now if I remove the comment tag from the applet and include that
code as a part of the applet program(which takes the InputStream
of the servlet and print the input),it works fine.
it means if i input "hello" in the textfield .press the "send"
button then this "hello" is written in the applet(via servlet
InputStream)
now this works only if I use "doPost" method in the servlet.
if i want to run the servlet now and see the data send from
the applet it works also.(But it does not work on clicking
the Refresh button in the browser.405 error).
please tell me the solution so that i will be able to see
the message send from the applet to the servlet when i
run the servlet excluding the code in the comment area
in the applet.
it is a bit confusing but if you try the code ,i think everything
will be clear.

thanks
asheet

+Pie Number of slices to send: Send
Please try this link. I haven't done much on applet-servlet communication. This link seems to give some usefule info.
http://pages.about.com/kmukhar/
regds
maha anna
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1015 times.
Similar Threads
some CODE here to work out!!!!
PLEASE HELP! FRANK
applet-servlet comm using obj serialization --- william,thomas, maha please help
Applet -Applet communication prb
please guys help me!!Moderators welcome(maha anna)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:43:59.