• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

localhost:8080

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, total beginner here. I'm going through a beginning Spring MVC book and I see this pattern http://localhost:8080/webstore. Do people always use the localhost:8080 when they want to test their web app on their local machines before deploying to a real web domain (www.sitename.com)? Thanks.
 
Marshal
Posts: 4668
305
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL you mention, http://localhost:8080/webstore relates to the pattern, http://<server>:<port>/<app-path>. When deploying locally, your server will always be 'localhost', or sometimes '127.0.0.1', and servlet containers such as Tomcat and Jetty will use by default port 8080. You can configure them to use a different port, but just for local testing most people don't bother. I know I never have.
 
Bartender
Posts: 20995
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually people will keep a test web server on their own machine just because it's convenient. You can start and stop it at will, deploy easily and run a debugger against it. And since "localhost" is the standard name for "my machine", that's where that part of the URL comes in.

The "8080" part is more problematical. All HTTP requests have to have - explicitly or implied - both a hostname and a port number. If you omit the port number ("http://localhost") then for http requests, your client will assume port 80. For https requests, it will assume port 443.

Because any port number below 4096 is protected on most systems, test servers usually operate on alternative ports. For the Tomcat server, the default setting for the server will be to look for http traffic on port 8080. Other webapp servers may use different port numbers. So since your test requests need to be routed to port 8080 (or whatever port the test server listens on, but the client's default is 80, that's the reason that you have the port number explictly stated: "http://localhost:8080".

Incidentally. DNS only resolves names to IP addresses. Port numbers are not part of what DNS can look up. So any server which listens for http on a port other than 80 needs the port number override on URLs, not just local test servers.
 
Ranch Hand
Posts: 310
18
MS IE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little offtopic from me.

Christine, for a total beginner I would recommend you to start with pure Java before you move start playing with Spring. Frameworks are tools to make development faster by providing a set of ready to use libraries. This way you can make things working, but you will have no idea why it is really working - all the logic that makes your program to work will be buried deep inside the framework.

The best way to start learning a new technology is to use it in it's pure form, without any additional libraries. That way you can learn how the fundamentals work and fully understand the given technology. With such knowledge you will understand the frameworks better and be able to use their full potential.

Once on StackOverflow there was a famous question from a person who learned a library first. The question was... "How to divide numbers in jQuery" - this is what learning libraries/frameworks does to people :-)
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!