Tomcat port number

J

John Smith

Is it possible to find the port number the web server is listening on. I
need to do this in the servlet init() method?

Many Thanks

Jon
 
M

Murray

John Smith said:
Is it possible to find the port number the web server is listening on. I
need to do this in the servlet init() method?

Many Thanks

Jon

I don't believe it's possible to do it in the init() method. The port number
is only associated with an individual request because the values can change
for different requests if the server is configured so use virtual hosts, or
other configs.

request.getServerPort()
 
J

John Smith

Thanks what I was trying to do was be able to construct the URL for a call
to the servlet at boot time? I can get the host, the port and path are all
that are stopping me.

Many Thanks

Jon
 
J

Juha Laiho

John Smith said:
Thanks what I was trying to do was be able to construct the URL for a call
to the servlet at boot time? I can get the host, the port and path are all
that are stopping me.

Hmm.. calling which servlet from where at boot time of what?

Are you trying to make something happen within some single app as the
application server is started (or more properly, when some webapp is
loaded into the application server)? Check the load-on-startup parameter
in web.xml servlet definition -- so, see the Java Servlet specification.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top