tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 최영규 <waste...@secure1.co.kr>
Subject About Servlet-Applet Communication
Date Mon, 09 Oct 2000 15:58:34 GMT
I have difficulty in Servlet-Applet Communication.
I go around SUN Developer Connection and try as some pieces of
advice I saw there.
I could transfer parameter from Applet to Servlet.
Like it.
   Using URL, URLConnection Object
   URL  url = new URL("http://hums/services/servlet/SomeServlet");
   URLConnection uc = url.openConnection();
   String  qry  =  URLEncoder.encode(  "qry"  )  +  "="  +  URLEncoder.encode(  qryString
 ) 
   uc.setDoInput(true);
   uc.setDoOutput(true);
   uc.setUseCaches(false);
   uc.setRequestProperty("Content-type",application/x-www-form-urlencoded"  ); 
    DataOutputStream  dos  =  new  DataOutputStream(  uc.getOutputStream()  ); 
   dos.writeBytes(  qry  ); 
   dos.flush(); 
   dos.close(); 

    And in  SomeServlet , HttpServletRequest req can catch parameter
   with req.getParameter("qry"); using doPost Method or service  method.
   But I don't know how servlet give response applet back..
   I tried HttpServletResponse.getOutputStream() or PrintWriter Object
  or DataOuputStream(HttpServletResponse.getOutputStream());
  But all failed in anyway..

   ps. I want to know communication with Object transfer in addition to Primitive Type with
DataOut(In)putStream..
  Of course,I guess ObjectOut(In)putStream will be used with implementing Serializable Interface.
  I want see any example..
 
     Regard Choi..
        
 
  
   
Mime
View raw message