Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get servername

843835Aug 27 2002 — edited Sep 16 2005
hi, everyone
I want to get servername from a servlet.
I know that I can get it from the parameter request by calling the method "request.getServerName()". But now I have to get the servername from method "init()" of HttpServlet. The code is as :

public class MyServlet extends HttpServlet {
public void init(){
String servername = xxx.getServername();
......
}
}

But I don't know how to do, and I don't know if it is possible. help me please.
Thanks .
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 14 2005
Added on Aug 27 2002
16 comments
283 views