I'm trying to save some information from an applet to a mySQL database using a Servlet. I can access the Servlet fine from a JSP but I can't get an Applet to connect to the servlet at all.
The code is as follows, any suggestions would be gratefully received.
Thanks in advance.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
I can't get an Applet to connect to the servlet at all
What does this mean - what happens when the code is run? Are there any exceptions?
Since you use getCodeBase, the servlet seems to be hosted on the same server as the applet (which is a precondition for this to work at all), but is the servlet really listening at the URL where the applet is hosted?
What does this mean - what happens when the code is run? Are there any exceptions?
The applet code executes in full without throwing any errors. On the servlet side nothing happens, the doPost method is not invoked (and no errors occur).
but is the servlet really listening at the URL where the applet is hosted?
Terribly sorry, but I'm not sure exactly what you mean by this, I'm new to applets and servlets.
Yes, the applet and servlet are both hosted on the same server.
The servlet has responded to requests from JSPs but I'm not sure if this answers your question.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
By "listening to the URL" I mean that a servlet is configured to respond to particular URLs (the "servlet-mapping" elements in the web.xml file). It would be a very unusual setup to map a servlet to a directory that contains files to be served. That seems to be what you are doing with the "getCodebase" call in the URL constructor.
Can you invoke the servlet manually through the browser?
Another things to check are the web server access logs, to make sure that the request reaches the server.
Liz Costelloe
Greenhorn
Joined: Nov 01, 2003
Posts: 17
posted
0
Hi Ulf,
I do think I have the servlet configured to respond to http://an.ip.address:8080/structures/Save. The web.xml file is included below and I am able to invoke the servlet manually through a web browser.
I have tried looking through the web server (JBoss) logs but I'm not sure where the access logs are stored in JBoss. If you happen to know this, I would be grateful if you could point me in the right direction - I will keep looking of course, but it would save me some time.
Many thanks.
[ May 15, 2006: Message edited by: Liz Costelloe ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
Your web app is named "structures". But in which directory is the applet - is it in the top-level directory? Only then would getCodeBase return the proper directory. It might be a good idea to print out the URL which the applet is trying to access; I'm not quite sure what the "spec" parameter does.
Can't help you with JBoss - I never used it.
Liz Costelloe
Greenhorn
Joined: Nov 01, 2003
Posts: 17
posted
0
Hey Ulf,
Quick line just to say thanks for all your help!! At long last I have this applet and servlet communicating. In the end I got out a TCP viewer and noticed that there were a lot of 'Java' connections stuck waiting for responses so I extended my code like so:
As a result communication was established There were a few errors along the way (Permissions and an EOF error) but now all is working smoothly.
Thanks again for all your help!! [ May 24, 2006: Message edited by: Liz Costelloe ]