While learning about servlets, I have been deploying and testing my web apps locally using tomcat. I wanted to see how to put one of my apps (which works fine on my computer) on the web just for a test, so I got some web space with godaddy and have been trying to put it on. No joy. At first I thought it must be the database not connecting properly, so I played around with that for a while, then, just to see that the info from the client was getting through to my servlet, I wrote a test app with literally an html page saying, "this is the servlet test" with a button that can be clicked, supposedly to send a post request to the server and then I'd get back some data from the servlet (Just a string to be displayed saying "response from servlet").
I deployed the test app locally on my own computer using the tomcat container and it worked fine, so I put it up on the web to see if it would work. Unfortunately not.
Naturally assuming that I couldn't possibly have done anything wrong I asked godaddy to check their systems and they said that 'Java was working fine on their systems'. I've checked that the file structure on the web is exactly the same as I've got it on my computer. And it is. I've mucked around with the DD to see if different fully qualified names for the servlet might work, but it didn't make any difference. Godaddy have said that checking to see that java is running fine on their systems is all they can do, so I'm wondering if anybody can give me a few ideas about what to try next.
Very grateful as always for any help.
Joe Lemmer wrote:to see if it would work. Unfortunately not.
What does "work" mean? Did you get an error message? What happened that was different from what you expected.
As general advice, I recommend making your "Hello World" servlet even simpler to see what is going on. It sounds like yours uses AJAX. That's certainly not the simplest servlet you can make. The simplest one accepts get requests and writes out hello world. That way you can call it directly from the URL bar in the browser.
If this simpler servlet works, you are doing something wrong in the other example and can slowly build back up to it to see where things break. If not, it could be the deployment descriptor or a setting.
Post back here once you've tried this and someone can give more pointers on what to try on that path.
So it's finding the file, but it's just a file.
I've used both the url:
and I get the same response.
Do you normally have to wait a while for an instance of the servlet to get running? I would phone godaddy again, but noone there knows anything about Java. Here's my servlet code anyway just in case I'm doing that wrong. Does anyone have any suggestions?
So, if you say that it works fine locally foryou, then it is just some tiny configuration problem.
Firstly, you dont have to add the .class to URL [unless you have some special mapping which I seriously doubt].
Can you show me the web.xml file for your application ? specifically the <servlet-class>, <servlet-name> and the <url-mapping> portions.
If you like to deploy .war files, you might be disappointed to know that they only explode the war files at 0100 PST every day....
They also have a weird (to me) way of handling regular servlets.. if you have a standalone servlet, such as my DateServlet, you must put it in your WEB-INF/classes directory. Then to access it you must go to: www.yoursite.com/servlet/YourServlet. They don't seem to understand web.xml files (which allow for servlet mappings, in case you aren't familiar) unless you deploy the whole site (or subsite) as a war file.
So I forgot about the web.xml (because my test servlet is stand alone) and put in the url as suggested and made some progress, although this was in the form of an HTTP Status 500 error.
One of the errors was:
I found out is due to the fact that I compiled my .java files with a more up to date version of java than on godaddy. I use JDK 1.6. GoDaddy use 1.5.
The other error was:
not sure what that is, but I'm going to try downloading and compiling with JDK 1.5 and see what difference that makes.
Thanks Dawn and Jeanne for your help
However , you might want to note that you'll need a deployment descriptor [read web.xml] to map your servlets to URLs... however simple your servlet or app be.
And the answer to your last query [servletexception] is that - the webserver/servlet container, while handling the URL send by you [path, that is] could not find a matching servlet to initiate [because you didnt provide a mapping - coz, no web.xml]
Provide a web.xml for your app, place the classes in WEB-INF/classes, and yes, compile with JDK5 - Your app should be functional.