• Post Reply Bookmark Topic Watch Topic
  • New Topic

localhost:8080  RSS feed

 
Christine Coleman
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.
 
Tim Cooke
Marshal
Posts: 3840
221
Clojure IntelliJ IDE 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.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE 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.
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • 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 :-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!