© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
Quick Links
Easy Studies

Getting Detail about Web Server Using Java


This program is the servlet, which has the methods to display information about its server. This Servelet has doGet () method which has two objects ServletRequest and ServletResponse.From ServletRequest we can get the details about the server. To display the name of the server you are using use the method getServerName () of the ServletRequest interface. To display the server port number use the method getServerPort (). You can also use other methods of the ServletRequest interface like getProtocol () to display the protocol you are using.

Getting Detail about Web Server Using Java :

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class GetServer extends HttpServlet{ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter pw = response.getWriter(); pw.println("The server name is " + request.getServerName() + "
"); pw.println("The server port number is " + request.getServerPort()+ "
"); pw.println("The protocol is " + request.getProtocol()+ "
"); pw.println("The scheme used is " + request.getScheme()); } }

Sample ScreenShot:

SLogix Student Projects

⇓ Student Projects ⇓
⇑ Student Projects ⇑