6 replies
by sampathr
to communicate applets to servlet , do the following.
URL newURL = new URL("http",hostName,port,newPath);Frame the URL
AppletContext context = getAppletContext();
context.showDocument(newURL,"bottom");
Here u could see that u can use the showDocument method of Appletcontext, which can be retrived from getAppletcontext().
I hope this will answer ur 2nd part of the question.
For the 1st part of question :
Use TrustedCode for the applet, then it will allow u to connect with database.
Sampath Ramanujan.
by sirishakoka
by ravalv
Hi,
U can use following code to communicate with the servlet from applet where p1 and p2 are the parameters and v1 and v2 are the values of the parameter which are passed to the servlet:
url = new URL("http://server:8080/servlet/servletname");
StringBuffer arg = new StringBuffer("?");
arg.append(URLEncoder.encode("P1") + "=" + URLEncoder.encode("V1"));
arg.append("&");
arg.append(URLEncoder.encode("P2") + "=" + URLEncoder.encode(V2));
url = new URL(url.toExternalForm() + arg.toString());
con = url.openConnection();
con.setUseCaches(false);
in = con.getInputStream();
DataInputStream data = new DataInputStream(new BufferedInputStream(in));
String incoming = data.readLine();
Alos at the servlet in response set the content type text/plain.
Vishal Raval
by ravalv
by sirishakoka
by sirishakoka
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending