how to communicate betwwen applet and servlet
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhishek_Mishra
Posted On:   Thursday, December 13, 2001 06:45 AM

i am sending my applet code.. this code is behaving properly and details are being fetched by servlet, but when i check for length of request in servlet it shows 0 why so?? due to which many problems are occuring?? is my way of sending request from applet to servlet is not proper?? what changes should i make??? APPLET CODE for sending request to servlet ------------------------------------------ //Sending Data through POST METHOD String protocol = getCodeBase().getProtocol(); System.out.println("[VfsAppletlogin] protocol : " +protocol); int port = getCodeBase().getPort(); Integer i=new Integer(port); System.out.print   More>>

i am sending my applet code..
this code is behaving properly and details are being fetched by servlet, but when i check for length of request in servlet it shows 0
why so??
due to which many problems are occuring??
is my way of sending request from applet to servlet
is not proper??
what changes should i make???




APPLET CODE for sending request to servlet
------------------------------------------
//Sending Data through POST METHOD

String protocol = getCodeBase().getProtocol();
System.out.println("[VfsAppletlogin] protocol : " +protocol);
int port = getCodeBase().getPort();
Integer i=new Integer(port);
System.out.println("[VfsAppletlogin] port : " +i.toString());
String host = getCodeBase().getHost();
System.out.println("[VfsAppletlogin] host : " +host);

String location = "/servlet/initlogin";
String ref=protocol +"://"+host +":"+ port+ "/servlet/Login?directory=SLMBank";
System.out.println("[VfsAppletlogin action] URL location 1");
URL testServlet = new URL(protocol, host, port, location );
System.out.println("[VfsAppletlogin] servlet url forwarding");
System.out.println("Destination URL: " + testServlet.toString());

auth1() ;


URLConnection servletConnection = testServlet.openConnection();

// inform the connection that we will send output and accept input
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
//change on 30'th nov

// Don't use a cached version of URL connection.
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);

// Specify the content type that we will send binary data

servletConnection.setRequestProperty ("Content-Type", "x-www-form-urlencoded");
servletConnection.setRequestProperty ("protocol", protocol);
servletConnection.setRequestProperty ("Host", host);
servletConnection.setRequestProperty ("port", i.toString());
servletConnection.setRequestProperty ("directory", "SLMBank");
servletConnection.setRequestProperty ("hb_number", no);
servletConnection.setRequestProperty ("user_name", user);
servletConnection.setRequestProperty ("password", passwd);
servletConnection.setRequestProperty ("savehbnum",remlogin1);
servletConnection.setRequestProperty ("change_pass", rempass1);
servletConnection.setRequestProperty ("institution", "101102726");
servletConnection.setRequestProperty ("Referer", ref);
System.out.println("[VfsAppletlogin action] All the property parameters have been set");

OutputStream out=servletConnection.getOutputStream();

out.flush();
out.close();

System.out.println("[VfsAppletlogin action] url connection opened with the servlet");
InputStream input = servletConnection.getInputStream();
input.read();
//inputStreamFromServlet.close();
}
catch(Exception e)
{
System.out.println("[VFSAppletlogin] Error in action performed post method "+e.toString()); }

// till here is postmethod


System.out.println("[VfsAppletlogin action] Data Succesfully sended to servlet ");
}

   <<Less
About | Sitemap | Contact