File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Printing server port number in java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Printing server port number in java file" Watch "Printing server port number in java file" New topic
Author

Printing server port number in java file

naresh bv
Greenhorn

Joined: May 28, 2007
Posts: 1
I want to get the port number of a server dynamically.
For ex: If I use tomcat server then I will get port number as 8080
If I use WebLogic then that will be 7001, so on....
How can i get that port number in normal java file.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by naresh bv:
I want to get the port number of a server dynamically.
For ex: If I use tomcat server then I will get port number as 8080
If I use WebLogic then that will be 7001, so on....
How can i get that port number in normal java file.


I could not get the questions properly.

Well 8080 is the default port for Tomcat and can always be changed.

One more confusing thing is normal java file ?

Do you mean a standalone program making request to server.
In that case you can have a configuration file which will have port numbers and server type.Can you can change the program to read the port number and host name where the server is located from the configuration file and construct the request dynamically.


Rahul Bhattacharjee
LinkedIn - Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

"naresh bv",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

http://java.sun.com/j2ee/1.4/docs/api/index.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing server port number in java file