Server information package com.ack.web.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ServerInformation extends HttpServlet { public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { res.setContentType( "text/html" ); PrintWriter pw = res.getWriter(); pw.println( "
" );
pw.println( "
Server Information: " + getServletContext().getServerInfo() );
pw.println( "
Servlet API Version: " +
getServletContext().getMajorVersion() + "." +
getServletContext().getMinorVersion() );
pw.println( "
Server Name: " + req.getServerName() );
pw.println( "
Server Port: " + req.getServerPort() );
}
}