This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi Yile, as far as I know, HTTP servlets are based on HTTP/HTTPS request/response semantics.. I have not seen examples where servlets can be invoked in non HTTP/HTTPS mode.
If you are asking if a servlet can be invoked in otherways instead of pointing to URL, Certainly yes. You can open a HTTPConnection to the servlet, but again 8080 is the protocol that is used underneath.
As you are aware HTTPServlet extends GenericServlet which is basically meant for protocol independent purpose. But I have not encountered any examples in real time. I hardly believe if they actually exist anymore.
Joined: Jan 27, 2011
Thanks for the reply. I want to access the application by a normal HTTP request without the :8080 socket descriptor. So the steps as I see them is that a user types in a URL (http://www.someserver.com/servletapp) and the apache or iis server gets the request. The webserver figures out somehow that servletapp is a servlet and not a web page, passes the request to tomcat which in turn runs the servlet. So the question is how does the webserver figure out that 'servletapp' (the URL does not have the :8080 socket descriptor) is a servlet and not a regular html page?
So the question is how does the webserver figure out that 'servletapp' (the URL does not have the :8080 socket descriptor) is a servlet and not a regular html page?
A Java-based web server is aware of the Java servlets it has deployed in its Servlet Container. It is designed to call the servlet in the same way it serves up an HTML file from the filesystem.
Whether there is or is not a port number in the path has nothing to do with executing servlets or serving static HTML files.
You can certainly access a Java web application with http://www.domain.com/servletapp. If you are getting errors then you have not deployed the servlet correctly.
I know that SomePage.html can invoke ServletName, but can an outside user invoke a serverlet directly by typing some non-8080 URL like http://www.somehost.com/Start where Start invokes my servlet?
What happens when you try it?
Joined: Jan 27, 2011
I get a 404 error. so how does one verify that the servlet and container are setup for a certain non-8080 URL?
Joined: Apr 16, 2008
First, port numbers are not included in domain names. Whatever web page examples you have read which show this are incorrect.
If you have not set up or registered a domain name mapping via DNS to a web server, then you still have a ways to go before making a servlet call using a domain name.
If you are getting a 404 error while trying to execute a servlet using a local URI, then you either have not deployed the servlet properly or the URI is incorrect.
I suggest a good reading of a Java Servlet book. Asdide, you can map a web server to any one of thousands of numbers. There is nothing special about 8080 or 80, except for the fact that they are used as a common "default" setting. This is easily changed, and changing it is a standard good practice in commercial settings.