JSP probe-virtual host JSP environment detection tool

Source: Internet
Author: User
<% @ Page contenttype = "text/html; charset = gb2312" %> <% @ page Import = "Java. Io. *, java. util. *, java.net. *" %> <%! String tblwidth = "700" ; String tblalign = "Center" ; String stros = System. getproperty ("OS. Name" );  Private  String getip () {string strtmp = "" ;  Try  {Strtmp = Inetaddress. getlocalhost (). gethostaddress (); Return  Strtmp ;}  Catch  (Exception e ){  Return  Strtmp ;}}  Private String getsystemenv () Throws  Exception {string OS = System. getproperty ("OS. Name" ). Tolowercase (); stringbuffer sb = New Stringbuffer ("" ); Process P = Null ;  If (OS. indexof ("Windows")>-1 ) {P =Runtime.getruntime(cmd.exe C ("CMD/C set" );}  Else  {P =Runtime.getruntime(cmd.exe C ("/bin/sh-C set" );} Bufferedreader br = New Bufferedreader ( New  Inputstreamreader (P. getinputstream (); string line;  While (Line = Br. Readline ())! = Null ) {Sb. append (line + "<Br>" );}  Return  SB. tostring ();}  Private  String getdrivers () {stringbuffer sb = New Stringbuffer ("" ); File roots [] = File. listroots ();  For ( Int I = 0; I <roots. length; I ++ ) {Sb. append (roots [I] + "" );} Return  SB. tostring ();} %> <HTML>  Body, TD, Th {font - Size: 9pt;} body {margin - Left: 0px; margin - Top: 0px; margin - Right: 0px; margin - Bottom: 0px;} A: link {text - Decoration: none;} A: visited {text -Decoration: none;} A: hover {text - Decoration: none;} A: Active {text - Decoration: none;}. style4 {color :# 000000 }. Style5 {font -Weight: bold; font- Size: 10pt;}. style7 {font -Size: 10 } --> </Style>  Class = "Style5"> & Nbsp; Basic Server Information </Span> </TD> </tr> <TD Height = "23" width = "20%"> & nbsp; server name </TD> <TD> & nbsp; <% = request. getservername () %> </TD> </tr> <TD Height = "23" width = "20%"> & nbsp; domain name/IP </TD> <TD> & nbsp; <% = request. getservername () %> <% = getip () %> </TD> </tr> <TD Height = "23"> & nbsp; server port </TD> <TD> & nbsp; <% = request. getserverport () %> </TD> </tr> <TD Height = "23"> & nbsp; client port </TD> <TD> & nbsp; <% = request. getremoteport () %> </TD> </tr> <TD Height = "23"> & nbsp; Client IP address </TD> <TD> & nbsp; <% = request. getremoteaddr () %> </TD> </tr> <TD Height = "23"> & nbsp; web server </TD> <TD> & nbsp; <% = application. getserverinfo () %> </TD> </tr> <TD Height = "23"> & nbsp; Operating System </TD> <TD> & nbsp; <% = stros + "" + system. getproperty ("Sun. OS. patch. level ") +" Ver: "+ system. getproperty ("OS. version ") %> </TD> </tr> <TD Height =" 23 "> & nbsp; server time </TD> <TD> & nbsp; <% = New Date (). tolocalestring () %> </TD> </tr> <TD Height = "23" width = "20%"> & nbsp; CPU Information </TD> <TD> & nbsp; <% = system. getproperty ("OS. arch ") %> </TD> </tr> <TD Height =" 23 "width =" 20% "> & nbsp; disk Partition </TD> <TD> & nbsp; <% = getdrivers () %> </TD> </tr> <TD Height = "23" width = "20%"> & nbsp; current user working directory </TD> <TD> & nbsp; <% = system. getproperty ("user. dir ") %> </TD> </tr> <TD Height =" 23 "> & nbsp; Path of this file </TD> <TD> & nbsp; <% = application. getrealpath (request. getrequesturi ()) %> </TD> </tr> </table> <br> <Table width = "<% = tblwidth %>" align = "<% = tblalign %>" border = "0" cellspacing = "0" cellpadding = "1"> <tr> <TD colspan = "2" Height = "22" bgcolor = "# e0e0e0"> <SpanClass = "Style4"> & nbsp; <Span Class = "Style5"> JAVA related information </span> </TD> </tr> <TD Height = "23" width = "20%"> <Span Class = "Style7"> & nbsp; JDK version </span> </TD> <TD> & nbsp; <% = system. getproperty ("Java. version ") %> </TD> </tr> <TD Height =" 23 "width =" 20% "> & nbsp; servlet version </TD> <TD> & nbsp; <% = application. getmajorversion () + ". "+ application. getminorversion () %> </TD> </tr> <TD Height = "23" width = "20%"> & nbsp; JDK installation path </TD> <TD> & nbsp; <% = system. getproperty ("Java. home ") %> </TD> </tr> <TD Height =" 23 "width =" 20% "> & nbsp; encoding </TD> <TD> & nbsp; <% = system. getproperty ("file. encoding ") %> </TD> </tr> <TD Height =" 23 "width =" 20% "> & nbsp; java class path </TD> <TD> & nbsp; <% = system. getproperty ("Java. class. path ") %> </TD> </tr> </table> <br> <Table width = "<% = tblwidth %>" align = "<% = tblalign %>" border = "0" cellspacing = "0" cellpadding = "1"> <tr> <TD colspan = "2" Height = "22" bgcolor = "# e0e0e0"> & nbsp; server environment variable & nbsp; </TD> </tr> <TD colspan = "2"> <% = getsystemenv () %> </TD> </tr> </table> <br> </div> </body> 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.