URL and servlets
Hi
I'm almost done with the biggest part of my project, so as soon as i can resolve this issue(i'm sure i'll have more, but this seems pretty big to me anyways, :)) i will be sitting pretty.
So i have an applet. This applet was designed to capture some data from a RS232 device(working perfectly). i have developed this all in its own project with its own jars and sorts(compiled under 1.3 for client requirement issues, hence the low compability).
I then have the rest of my project in which i embedd this applet(using a AJAX HTML object).
The problem is sending the captured data from the applet to the server(servlet).
While trying to come up with a solution to this, i stumbled across the URL and URLConnection class and i have been going through the tutorial offered here:
http://java.sun.com/docs/books/tutorial/networking/urls/urlInfo.html
I'm just having a hard time trying to understand how is it that the servlet can get the info from the applet.
My applet code isn't pretty and i don't even think it is right for the purpose that i want it for.
Basically i want the applet to write to the URL that it risides on and then i want the servlet to retrieve the URL with the variable i attach on the applet side.
Ok so here is my applet code,like i said this is working off the tutorial code....
String gogoTag =""+myTag[1];
try{
url =new URL(""+getCodeBase());
myCon = url.openConnection();
myCon.setDoOutput(true);
OutputStreamWriter out =new OutputStreamWriter(myCon.getOutputStream());
out.write("tag="+gogoTag);
out.close();
BufferedReader in =new BufferedReader(new
InputStreamReader(myCon.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) !=null){
System.out.println(decodedString);
}
in.close();
}catch (MalformedURLException e1){
e1.printStackTrace();
}catch (IOException e1){
e1.printStackTrace();
}
So when i run my applet the output in the JVM console is this
<html><head>
<meta name='gwt:module' content='net.impro.ajax.reports.admin.admin'>
<meta name='gwt:property' content='tag=18845418652'>
</head><body>
<iframe id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
<script language='javascript' src='gwt.js'></script>
</body></html>
So it does right what i want it to ut i don't think its to the URL, sigh :( lol
What or how do i write the info i want from the textbox of an applet to the servlet? Does the servlet also need to connect via a URLConnection object to get the variable or can i just use this.getThreadLocalRequest();
(My servlet extends RemoteServiceServlet which in turn extends HttpServlet) or do i just have to go do more reading on the URL and URLConnection class?
Any advice is appreciated
Thank you
:)

