wood burning stoves 2.0*
The moose likes Servlets and the fly likes applet and servlet not communicating... any ideas? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "applet and servlet not communicating... any ideas?" Watch "applet and servlet not communicating... any ideas?" New topic
Author

applet and servlet not communicating... any ideas?

Abi Evans
Greenhorn

Joined: Jul 08, 2009
Posts: 4
I adapted an applet I found on the internet that allows users to record a voice message which is then saved on their local system as an audio file. I am now trying to change this so that the file is saved on the server instead. I have written a servlet (also adapted from an example I found on the internet) which is meant to get the audio data from the applet but nothing happens. The code compiles fine and I don't get any error messages.

I am new to Java and Tomcat and would appreciate any suggestions you might have to make this work. The code for both the applet and the servlet is pasted in below:

The applet


The servlet:

Abi Evans
Greenhorn

Joined: Jul 08, 2009
Posts: 4
I'm starting to think the problem may lie with the way I have my files set up on Tomcat. I'm using version 6.0.20

The HTML file and applet (recorderV3.jar and recorderV3.html) are in webapps/ROOT/test/
The servlet (receiver.class) is in webapps/ROOT/test/WEB-INF/classes/
My web.xml file is in webapps/ROOT/test/WEB-INf and looks like this:


I can run recorderV3.html (although nothing happens) but if I try to run the servlet directly using http://localhost:8080/test/receiver , I get a status 404 error message.

Do I need to do anything else to get it running? Any ideas?

Thanks,
Abi
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

For a start, your servlet has to be in a package.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
The applet uses http://localhost:8080/receiver, not http://localhost:8080/test/receiver. Does that one work if you access it directly?


Ping & DNS - my free Android networking tools app
Abi Evans
Greenhorn

Joined: Jul 08, 2009
Posts: 4
How do I put it in a package? Is that the same thing as a .jar file? And where does it go when it's in a package?

Sorry if these are basic questions. I have three textbooks and none of them explain anything about packages. Only one mentions deploying servlets and that just says to put the .class file inside WEB-INF/classes.

Thanks for your help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

It's a basic Java concept. You must be comfortable with it before attempting something as advanced as servlets.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Abi Evans
Greenhorn

Joined: Jul 08, 2009
Posts: 4
Ulf: thanks for pointing that out. Yes, http://localhost:8080/receiver does work if I access it directly - it makes a test.au file on the server. However, if I try to access it through the applet, nothing happens.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
I'd advise to put a few strategically placed System.out.println statements in the applet's "run" method and the servlet's "doPost" method so you know they're being called. I take it there are no exceptions either on the client nor the server?

By the way, you should not use System.exit in applets; they're not going to work anyway.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: applet and servlet not communicating... any ideas?