• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URL and mapping to servlets

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So all of the servlet examples show http://www.somehost.com:8080/ServletName. That works ok. but from outside users are going to type http://www.somehost.com/SomePage.html. 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?
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yile Ku wrote:So all of the servlet examples show http://www.somehost.com:8080/ServletName. That works ok. but from outside users are going to type http://www.somehost.com/SomePage.html. 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?



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.
 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
M-
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To avoid the 8080, configure your server to listen on the default port of 80.
 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache or IIS are listening in port 80.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you want your servlet's application container to listen on port 80 instead? Then turn off those applications which are already using that port.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?

 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get a 404 error. so how does one verify that the servlet and container are setup for a certain non-8080 URL?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic