I am a JSP/Servlet newbie currently adding the first servlets to a web site that had been static all along. My local instance worked great but the servlets did not respond on the test instance. Apparently, my hosting service provider requires me to use an invoker servlet mapping.
Adding this to local web.xml broke the application but the servlets respond on test instance (when their calls are not preceded by another servlet call). A Servlet fails when it is called immediately after another servlet has been called.
What I saw happening on test is URL for first call is of the form:
And URL for the second call became:
The servlets are invoked using "href=servlet/<servlet-name>?Id="
How can I avoid the inclusion of 'servlet' in the URL and reset the URL to the JSP page it navigates to after processing of the servlet? Any kind of help is appreciated.
Thank you very much.
P.S.: I am also trying to enable the Invoker servlet on local so I can troubleshoot easier. I went through the changes to Tomcat's web.xml and context.xml. However, my local servlets did not respond even after calling them using "href=<servlet-name>?Id=". Is there a way I can check if my invoker is active?
As for the URLs which your code is generating, our FAQ page RelativeLinks explains how to handle that issue.
Advice #2: if Advice #1 cannot be followed for whatever reason, the invoker is disabled by default. And with good reason. it should not be used. Ever. Ever. Never.
Advice #3: see Advice #1 (for emphasis)
So, I read the page on contextual paths and modified my application accordingly. In the meanwhile, I got my hosting provider to disable the invoker servlet as well. Now, the application works in local but does not work on the test server. Could anyone please point to me what I am missing?
This is a URL for a servlet being called on localhost.
This is the URL call for the same servlet on the test instance:
This is the error message from Apache that is shown in my browser.
The requested URL /my-app/DeleteDocument was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8d mod_jk/1.2.19 Server at www.xxx.org Port 80
The catalina.out has recorded no error messages.
This is the servlet mapping for the DeleteDocument servlet.
This is how the DeleteDocument servlet is being called:
href = contextPath + DeleteDocument?Id=......
Does your provider have an instruction pare somewhere on how to deploy apps?
Apps are deployed by FTP to the server and calling the said URL for restarting Tomcat. Earlier, I remember using a URL where I could upload a WAR file for deployment and click buttons on the page for stopping and starting the server, though I can't seem to find it now.