Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet and servlet not communicating... any ideas?

 
Abi Evans
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a start, your servlet has to be in a package.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The applet uses http://localhost:8080/receiver, not http://localhost:8080/test/receiver. Does that one work if you access it directly?
 
Abi Evans
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a basic Java concept. You must be comfortable with it before attempting something as advanced as servlets.
 
Abi Evans
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic