Sorry : something happened when I sent my last email, removing all line
breaks.
Here is the real file, please ignore last : So sorry.
Hi All,
I have a LOCAL applet (with a LOCAL html page) that is trying to
send an object to a servlet that is sitting on a REMOTE server.
I need to pass an object between the two.
* I have placed a hole in my firewall
* my local applet is signed
The servlet will not accept the object.
I have not edited the web.xml file (since I do not know if it would
help)
I did edit my server.xml file in order to specify the http port (8888).
The message on tomcat reads :
Status code:404 request:R( +
/signed/WEB-INF/classes/SERVLET_receiveSIMOBJ2.class + null)
msg:null
I know that local applets are not supposed to talk to servlets on
different hosts, but I have also been told that with TCP, a firewall
hole,
and a signed applet, it should work.
Can it ?
Is there some way on Tomcat to get around this problem ?
This code works either locally or remotely as long as the code is on
the same machine.
Thanks so very much in advance, it is genuinely appreciated.
Here is some critical code :
//==================== LOCAL APPLET
String urlstr =
"http://machine.cluster.net:8888/signed/servlet/SERVLET_receiveSIMOBJ2";
// where machine.cluster.net is the server
// 8888 is the port with the hole
try {
URL servletURL = new URL (urlstr);
URLConnection uc = servletURL.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type", "application/octet-stream");
ObjectOutputStream objOut =
new ObjectOutputStream
(new GZIPOutputStream(uc.getOutputStream()));
// sent it to the servlet
System.out.println("APPLET: SENT TO SERVLET asldkfad" );
objOut.writeObject((Object)simobj);
objOut.flush();
objOut.close();
System.out.println("APPLET : READING OBJECT BACK " );
ObjectInputStream objIn =
new ObjectInputStream
(new GZIPInputStream(uc.getInputStream()));
// read an object from the servlet
simobjout = (SIMDataOBj) objIn.readObject();
// ooo.junk = "JUNK";
System.out.println("Received info from Servlet " + simobjout.A +
simobjout.B + simobjout.C + simobjout.D);
objIn.close();
return simobjout;
}
//**************************************** END LOCAL APPLET
//**************************************** REMOTE SERVLET
public void doPost (HttpServletRequest request,
HttpServletResponse response) {
System.out.println("In Servlet's do post - reached "); // NEVER
REACHED
try {
ObjectInputStream objIn = new ObjectInputStream
(new GZIPInputStream(request.getInputStream()));
// set up output stream
response.setContentType("application/octet-stream");
ObjectOutputStream objOut = new ObjectOutputStream
(new GZIPOutputStream(response.getOutputStream()));
SIMDataOBj simobj = new SIMDataOBj();
simobj = (SIMDataOBj) objIn.readObject();
WriteXML (simobj);
System.out.println("In Servlet ::: Printing the Object's contents " +
simobj.A + simobj.B + simobj.C + simobj.D);
simobj.A = "1 !!!!!!!!!!!! 1";
simobj.B = "2 !!!!!!!!!!!!!!!!!! 2";
simobj.C = "3 !!!!!!!!!!!!!!!!!!!! 3";
simobj.D = "4 !!!!!!!!!!!!!!!!!! 4";
objOut.writeObject((Object)simobj);
objOut.close();
System.out.println("End Servlet Communication ");
}
//**************************************** END REMOTE Servlet
//**************************************** both local and remote
SIMDataObj
class SIMDataOBj extends Object implements Serializable
{
String A, B, C, D;
SIMDataOBj(){
A= new String ("THIS " );
B= new String (" IS " );
C= new String (" A " );
D= new String (" D " );
}
}
//**************************************** END both local and remote
SIMDataObj
========================LOCAL HTML with signed applet
======================================
<HTML>
<BODY>
<APPLET CODE="AppletToServletSIMOBJ.class"
ARCHIVE ="Stry.jar"
WIDTH=430 HEIGHT=270
name=AppletToServletSIMOBJ
></APPLET>
</BODY>
</HTML>
========================END LOCAL HTML with signed applet
======================================