Link to home
Start Free TrialLog in
Avatar of pravin_tiwari
pravin_tiwari

asked on

applet to servlet communication

my applet is making a URL connection to the servlet. now the problem is when i publish in the web applet doesn't get the servlet and i get a exception at the applet end as : FileNotFound Exception. even the url is proper as i use to work before and suddenly it has started throwing exception
help !
Avatar of Ravindra76
Ravindra76

Hi pravin_tiwari

1. First check the port on which your applet is running and the port on which servlet is running.

If there are samw port your url will like this

http://yoursite/servlet/YourServletName

2.If they are running on different port, you have to mention port on ehich servlet is running.

http://yoursite:servletport/servlet/YourServletName.

In my view, your problem is applet and servlet are running on different port.

IF they are running on same port are you mentioned the port as in 2 above,

Just post stacktrace and

the code which actually connecting with servlet



Avatar of pravin_tiwari

ASKER

hi ravindra76,
   well as you have mentioned in your comment we are using the second option. the funny thing is it was working few days back but now suddenly it is giving an exception : FileNotFound 202.54.20.85//servlet/RCServlet.

my code snipplet is:

        public void getData() {
             try {
                   System.out.println("String ==> " +input);
                   URL connect = new URL("http://202.54.20.85:8081/servlet/RCServlet");
                   URLConnection c = connect.openConnection();
                   System.out.println(" just after url connection ");
                   c.setDoInput(true);
                   c.setDoOutput(true);
                   OutputStream os = c.getOutputStream();
                   ObjectOutputStream oos = new ObjectOutputStream(os);
                   oos.writeObject(input);
                   oos.close();
                   os.close();
}



thanks very much for your assistance!
>>>

FileNotFound 202.54.20.85//servlet/RCServlet.

Hi,

Here port 8081 is missing in stack trace.

If you don't laugh at cheap trick,

compile Applet and Servlet file once recently and restart the server which is running the servlet

Best of luck
ASKER CERTIFIED SOLUTION
Avatar of chintal_stud
chintal_stud

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

 Have U checked Ur classpath settings.
U say published the applet, so I assume
it is a different m/c.Could be that
the classpath was set wrongly on the server m/c and U were able to access the servlet becos' U had a local copy
on Ur hard disk.
hi all,
    thanks for your valuable comments...finally i got the solution and it was that my servlet was throwing an error. but since i was calling the function of the applet that establishes the stream with servlet from java script i was getting filenotfound exception.
i think chintal stud is write.

thanks to all anyway.