Faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

71 of 108 people (66%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How to send data from servlet to javascript variables

Jul 30th, 2009 22:53
s3odia s3odia, forum net tr, chat alarab, haytham ali, hindusthan jobs, ha mo, Joseph Ess, HARI K, www.javasoft.com, Java Servlet Programming (Hunter and Crawford 1998)


Javascript can access public methods on embedded applets, so my script 
invokes a method on an applet which uses the java.net.URL class to 
contact the servlet (see the Java API for details on URL and 
URLConnection, exception handling code has been ommitted here):  	
 url = new URL(<servlet URL>);
 conn = url.openConnection();    
 DataOutputStream out = new DataOutputStream(conn.getOutputStream());
 out.writeBytes(args);
 out.flush();
 out.close();
Now, the applet reads in the reply from the servlet and returns the 
reply text to the Javascript caller for processing. 
http://www.s3odia.com
http://www.s3odia.com/f2/
http://www.s3odia.com/f4/
http://www.s3odia.com/f5/
http://www.s3odia.com/f6/
 InputStream is = conn.getInputStream();
 DataInputStream in = new DataInputStream(new BufferedInputStream(is));
 String str = in.readLine();
 in.close();
 return str;
One caveat:  when the returned String pops back up in your Javascript 
code, it will be a Java, not a Javascript string.  To parse using 
Javascript, you will need to create a Javascript string:
str = new String(anApplet.getAppletInfo())
online video izle tr tube http://www.videotrtube.com/
firmalar sirketler rehberi http://www.sirketfirmarehberi.com/ firma
sirket rehberi adres telefon bilgileri
full forum http://www.forumnettr.com/forum/ 
secilmis youtube videolari http://www.youtubevideolari.net/ youtube videos
full program full oyun http://www.forumnettr.com/