Servlet to applet communication: with out polling
hi,
i need to write an applet which captures the realtime data as it appears in the server. Is this possible with out polling ther server at constant intervals? i.e... is it possible for the server to push data to an applet (say applet first registers etc etc with the server)
One more thing..say applet had opened a connection with server and opened a stream. Now is it possible for it to keep listening over the connection so that server puts the info over the connection when ever it has it and the client displays the info when ever it receives it.
Any pointers would be helpful.
[email protected] wrote:
hi,
i need to write an applet which captures the realtime data as it appears in the server. Is this possible with out polling ther server at constant intervals? i.e... is it possible for the server to push data to an applet (say applet first registers etc etc with the server)sure it's possible
One more thing..say applet had opened a connection with server and opened a stream. Now is it possible for it to keep listening over the connection so that server puts the info over the connection when ever it has it and the client displays the info when ever it receives it.
Any pointers would be helpful.i'm not sure what the best way is, but I've done it with Sockets and ObjectOutputStream
Similar Messages
-
How can I use URLConnection to use applet communication with servlet?
I want to send a String to a servlet in applet.I now use URLConnection to communicat between applet and servlet.
====================the applet code below=========================
import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.net.*;
//I have tested that in applet get data from servlet is OK!
//Still I will change to test in applet post data to a servlet.
public class TestDataStreamApplet extends Applet
String response;
String baseurl;
double percentUsed;
String total;
public void init()
try
java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
//String currenturl=new String("http://lib.nju.edu.cn");
java.net.URLConnection con = url.openConnection();
//URL currentPage=getCodeBase();
// String protocol=currentPage.getProtocol();
// String host=currentPage.getHost();
//int port=currentPage.getPort();
// String urlSuffix="/servlet/dataStreamEcho";
// URL url=new URL(protocol,host,port,urlSuffix);
// URLConnection con=url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
PrintWriter out=new PrintWriter(byteout,true);
String currenturl=new String("http://lib.nju.edu.cn");
String var1=this.encodedValue(currenturl); //encode the data
String data="currenturl="+var1;
out.print(data);
out.flush();
con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
byteout.writeTo(con.getOutputStream());
BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while((line=in.readLine())!=null)
System.out.println(line);
catch (Exception e)
e.printStackTrace();
private String encodedValue(String rawValue)
return(URLEncoder.encode(rawValue));
=========================The servlet code below=====================
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class DataStreamEcho extends HttpServlet
{public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
Runtime rt = Runtime.getRuntime();
out.println(rt.freeMemory());
out.println(rt.totalMemory());
response.setContentType("text/html; charset=GBK");
request.setCharacterEncoding("GBK");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession();
ServletContext application=this.getServletContext();
String currenturl=(String)session.getAttribute("currenturl");
out.print(currenturl);
=============================================================
I have done up,but I found the program don't run as I have thought.
Can you help me to find where is wrong?Very thank!You are trying to pass the current URL to the servlet
from the applet, right?
Well, what I put was correct. Your servlet code is
trying to read some information from session data.
request.getInputStream() is not the IP address of
anything...see
http://java.sun.com/products/servlet/2.2/javadoc/javax
servlet/ServletRequest.html#getInputStream()
Please read
http://www.j-nine.com/pubs/applet2servlet/Applet2Servle
.htmlNo,you all don't understand I.
I want to send an Object to the server from a applet on a client.not url only.I maybe want to send a JPEG file instead.
All I want is how to communicate with a servlet from an applet,send message to servlet from client's applet.
for example,Now I have a method get the desktop picture of my client .and I want to send it to a server with a servlet to done it.How can I write the applet and servlet program?
Now my program is down,But can only do string,can't not done Object yet.Can anyone help me?
=======================applet=============================
public void init()
try
java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
//String currenturl=new String("http://lib.nju.edu.cn");
java.net.URLConnection con = url.openConnection();
//URL currentPage=getCodeBase();
// String protocol=currentPage.getProtocol();
// String host=currentPage.getHost();
//int port=currentPage.getPort();
// String urlSuffix="/servlet/dataStreamEcho";
// URL url=new URL(protocol,host,port,urlSuffix);
// URLConnection con=url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
PrintWriter out=new PrintWriter(byteout,true);
String currenturl=new String("http://lib.nju.edu.cn");
String var1=this.encodedValue(currenturl); //encode the data
String data="currenturl="+var1;
out.print(data);
out.flush();
con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
byteout.writeTo(con.getOutputStream());
con.connect();
BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while((line=in.readLine())!=null)
System.out.println(line);
catch (Exception e)
e.printStackTrace();
=======================servlet=============================
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
response.setContentType("text/html; charset=GBK");
//request.setCharacterEncoding("GBK");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession();
ServletContext application=this.getServletContext();
//String currenturl=(String)session.getAttribute("currenturl");
String currenturl=(String)request.getParameter("currenturl");
out.print(currenturl);
File fileName=new File("c:\\noname.txt");
fileName.createNewFile();
FileOutputStream f=new FileOutputStream(fileName); //I just write the String data get from
//applet to a file for a test.
byte[] b=currenturl.getBytes();
f.write(b);
f.close();
} -
Applet communication with struts servlet
Hi
I�ve seen a lot of examples where a Java applet communicates with a servlet.
I�ve made a web application using Struts, and i would like to know if it is possible to use an applet (View) and send to Stuts some data, I mean, call an action like http://localhost:8080/ViewRoads.do.
Is it possible? ,Where can I find some examples about?, could anyone explain how would it work?, any good book to read about?.
Thank you.I'm sorry but don't you have a communication source code example between a servlet and an applet that does work ? I'm looking for one of these since Two days already.
thanks -
Hi,
Can an applet communicate with Microsoft DLL.
I want to save the content of an applet to database at server side.
Problem is there is no java envirnoment at server side (it has dlls).
What is the best way to do this. The content of the applet has to be savea at sever side not at client.
Thanxdeepakshettyk,
Two options that come to mind are:
1) have the applet use JDBC to connect to its host server's database directly. Typically this entails having type4 JDBC drivers installed and available.
2) have the applet itself connect back to its host server's webserver (IIS?), and have a server-side agent (ASP?) record data sent back to a database. See Marty Hall's book, 'Servlets & JSP', from Prentice Hall, for code examples.
--A -
Doubt about applet communicating with the SIM
Greetings,
I have this doubt: I am developing a web site which contains a java applet. The web site is going to be available at some web server. The web site is going to be accessed by mobile phones. The idea is that, somehow, the applet communicates with the mobile phone and extract info from the SIM Card for authentication. I still wondering if it is possible and the possible drawbacks or alternatives.
Thank you in advance,
FernandoHi,
you definitely have to sign your applet to do that.
Check in the forum "Security -> Signed applet". You'll find the information you need to sign an applet.
For example check at: http://forum.java.sun.com/thread.jsp?forum=63&thread=174214 -
Do not remove information about the community with out replacing said information.
Policy changes ok. What things are about, or the meaning of items, should stay here until something is new to replace these pieces of information.
Solved!
Go to Solution.Heather_VZ wrote:
Hey Prisaz-
Can you please elaborate? Which pieces of information are you talking about? We don't delete information and very rarely do we archive things- and even then, they are all searchable. If you can give me more specifics, I'll be happy to do some research to see what's up.
Thanks,
Heather
My bad. I guess with newer information, the older Jamie_Lee stuff regarding user levels, has just been bumped towards the bottom, and is still there, as pointed out by SomeGirl. I just over looked most of it.
I just posted this because of other items being discussed. Please disregard, as it was an error on my part. The information is still there, but with the last site upgrade it is not exactly in the same place. (sort of) -
Swing based applet communication with javascript
Hi
In my browser based application, the GUI has two part one contains the swing based applet and other is html based text area. Applet contains the list of text files.
My requirements is that if user double clicks on a file the, text area should display the name or path or content of file. I facing problem at very first level, how to capture the swing event in java script of browser?
Thanks in advance!!! :)Hi
In my browser based application, the GUI has two part one contains the swing based applet and other is html based text area. Applet contains the list of text files.
My requirements is that if user double clicks on a file the, text area should display the name or path or content of file. I facing problem at very first level, how to capture the swing event in java script of browser?
Thanks in advance!!! :) -
Communication with other domain
Hi,
An internal application (.exe developed in Delphi) at a
clients server (
no webserver) can communicate ( JSON protocol) with other
applications, also web based.
While testing the AS2 / AS3 classes ( from
http://www.json.org ) in the Flash
IDE (ctrl-enter) their was no problem. I made a connection on a
static IP-adres with open port and could send/recieve json-objects.
So far so good.
When publishing it for a html page, the trouble began. The
known security problem.
Is there a solution?
We don't know where to put the crossdomain.xml because there
is no root! There is just an application listening to an open port
on a static IP adres.
Just a single executable listening to an open port if a
request is comming in so it can send an answer.
Is there a solution?
How does the flash player finds out if a crossdomain.xml is
avalable?
Does it send a request also? Is it ok to generate a
crossdomain.xml on the fly on that request?
Help us please!I think I understood the following:
- Cards have a special applet called Card Manager (or Security Domain) for example to load and delete other applets
- Communication with the Card Manager goes over a secure channel with specific keysThat is correct
Questions:
- Are these keys 'open' so they can be used for every card of the same type?Development cards generally have know keys that can be used. When you go into production, your cards will have a unique (each card in fact will have its own key)
- Are these keys set by the factory and maybe reset by a distributor?Both. The card issue can also set the keys before sending the card out. Check the GlobalPlatform Key Management System specification from the GP website for more details on key management.
WrappedCommand --> 80 CA006600
Response <-- 664C734A0607...(I'll post all bytes if necessary)...9000Can you provide the full response from the card?
Can I somehow check if my Card is already blocked (too much failed attempts?) without waisting another attempt?No. If you have exceeded the tries your next INIT UPDATE will fail. You should have 10 per card with the JCOP cards from memory. Some Gemalto cards lock after 5.
Cheers,
Shane -
2-way communication with an Applet, is it possible?
I have read a couple of things on the internet that states that Applets cannot create ServerSockets. Is it really true, that you cannot directly communicate to an Applet unless it is polling a server???? There must be some other way, if any one can help, I would be greatly appreciative.
Thanks!
BlaineI have read a couple of things on the internet that
states that Applets cannot create ServerSockets. Is it
really true, that you cannot directly communicate to
an Applet unless it is polling a server???? There must
be some other way, if any one can help, I would be
greatly appreciative.
1. An applet can do anything that java can, including opening sockets to anything it wants, JNI, file access, etc. However, an applet works in a sandbox and normally it can't do any of those things. So you must do additional work to allow it to do such.
2. A socket back to the server is a two way communication pipe. Information can move both ways. In most designs this is the only way that you want communications to move.
3. An applet talking directly to another applet probably isn't a good idea. There are several reasons, one that springs immediately to mind is that the two boxes in the communication might not be addressable to each other (both have private IPs and are on different subnets.) With a server in the middle this is not a problem, but it is not possible otherwise. -
My MacBook is not connecting to the host computer for the printer. The host computer has a static IP address which is different from the IP address that the laptop is looking for. How do I change the laptop so that it looks for the host computer's correct IP? The laptop is connected to the router. I know this because I can get on the internet with the laptop.
The host computer is Dell and the operating system is Windows 7. The printer is an Epson, and it is wired to the host computer with a USB cable. It does have host printing turned on.
The three have been working harmoniously for a long time. The router had to be reset; and after that, the MacBook documents would no longer print.
We created a new static IP address on the Dell but the MacBook is not recognizing it. We have researched the internet trying to figure out how to make the MacBook locate and recognize the correct IP address from the Dell so they can communicate with each other. The laptop is not communicating with the host computer because is is looking for the wrong IP. The host IP is 192.168.1.245 and the laptop is looking for 192.168.15.237.
I hope everything is clear. The person who originally set it up is no longer available to help me. Thank you for any help you may give me. -
How to poll a blob using db adapter, with outer joins condition
Hi All,
We are trying to poll tables which contain column types as long and blob, we are using relationships in adapter and kept outer joins. by this we got select distinct t1.document .....etc
distinct keyword cannot be used for blobs.
is there any way to poll these tables having blob column types with outer joins.
thanks a lot in advance,
RRHi,
Procedure will be an explicit Invoke not Polling. If you can alter you design such that your BPEL process instead of polling gets triggered by some external entity (Java, PL/SQL, Scheduler, another BPEL etc.), you can put the data fetching logic in the procedure and call this procedure from your BPEL process to get the data. And your BPEL process is called periodically at an interval by an external entity.
Also see if you can restrict the duplicate records at the database level itself. Polling, AFAIK, is limited in terms of customization and wouldn't be easy to customize. However, would like to learn a way if someone has.
Regards,
Neeraj Sehgal -
Query to find out controls displayed as in UI for an applet,along with view
Hi,
I am looking for a query to find out list of all the controls as displayed in UI applet along with applet's view.
Please note that in the query only mapped controls (those displayed in UI ) should come up.
Regards,
KunalHi,
If the EUL is an apps mode (EBS) EUL then the eu_username column is the apps user id or apps resp id. If you want to show only the responsibilities and convert those ids to names then you need to use the EUL5_GET_APPS_USERRESP function like this:
select ba_name, ba_developer_key, EUL5_GET_APPS_USERRESP(eu.eu_username, 'R') responsibility_name
from eul5_bas ba
, eul5_access_privs ap
, eul5_eul_users eu
where ba.ba_id = ap.gba_ba_id
and ap.ap_type = 'GBA'
and ap.ap_eu_id = eu.eu_id
and eu.eu_role_flag=1
order by 1,2,3Rod West -
VB Client communicating with a Java servlet
Hi,
I have a java servlet and I would like to have a VB application communicating with the servlet.
Can I do it ? and if yes, how to do it.
Thanks in anticipation,
AyanaThe VB client can open an internet or Http connection to the servelet, send a request and parse the response. We've done it here but I don't know exactly which ActiveX control the VB guy uses.
Also look into using webservices. -
Communicating with Servlets....
hi!
Wat are all the different ways in which the JSP used to communicate with Servlet?
Thanx,
Rgds,
SasiJsp page communication with Servlets....
web.xml -- Servlets loaded during application startup
struts config -- Servlet mapping (w.r.t struts).
and u can import servlets in jsp and can use it... there are so many possible ways of using servlets coz jsp pages inturn convert into servlets and got executed..... -
Servlet Communication with Java WebStart
Hi there,
we have an application that works fine with Java WebStart whenever we start it in a local area network. But from outside the LAN the application cannot communicate to it's servlets. I use the codebase IP address with the servlet runner's port (http://<codebase IP>:port/) as URL for servlet communication, but the application's request never reaches the servlets.
My question is now, if anyone had the same or a similar problem with servlet communication using Java WebStart, or if anyone knows, if that might be a problem with proxy configuration.
The servlet runner we use, is JServ from Sun (JSDK2.0) and the webserver where it is running on is not behind a firewall or a proxy, but the client PC with the web start application is.
Thanks,
KatjaThank you for your early reply. But I think, that's not the problem.
I get no security error and the webserver is identified the same way it is in the jnlp file. Also my application is not running in the Sandbox. My assumption is, that the http-request to the servlet does not go through the proxy server between my PC and the PC the servletrunner is running on.
I wonder if I have to configure my application to use a proxy server for communication with the servlets instead of the direct http-request to the servlet runner?
Maybe you are looking for
-
Im too worried about the battery percentage while playing a game on my iphone 4s.so that,i decided to play a games and charging at the same time.im too worried for my battery problem on the future.please give a conclusion.
-
Trace File in pro*c program !!
Hiiii, I want to set the trcae file in my pro*c program but unable to do so. can anyone here help me out ... also i would like to know whether we can generate trace file for remote database connections, in my client program. I was using the syntax as
-
"Image Capture" not available on my Mac
I have a Macbook Pro OS X Mavericks 10.9.5, the mid-2014 model. I don't have image capture on my mac but i have iPhoto, how do I download it?
-
Using CSS With id=form1:txtbox1
Author: Mike12779 Sep 7, 2004 5:27 PM I am having a problem using CSS with the id's that JSF creates for the components on my page. After specifying an id="txtbox1", the rendering of the page changes my id to "form1:txtbox1". This is giving me proble
-
What operating system version are you using ?
For the last few weeks I have been using v5.0.0.592 Very impressed with it I must say