文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>tomcat 输入IP和端口跳转到自定的路径

tomcat 输入IP和端口跳转到自定的路径

时间:2010-02-25  来源:wizardzj

在ROOT应用的写个jsp文件,暂定义为a.jsp,加入以下代码


<%@ page import="java.net.HttpURLConnection, java.net.URL, javax.net.ssl.*, java.security.*" %>

<%

 String requestedURL = request.getRequestURL().toString();
 int responseCode = -1;
 String fileName = null;
 URL url = new URL(requestedURL+"/admin");//modifyinggggg
 if(request.isSecure())
 {
  try {
   SSLContext sc = SSLContext.getInstance("SSL");
   sc.init(null, null, new java.security.SecureRandom());
   HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
   // Create a HostNameVerifier to verify nothing ...
   HostnameVerifier hv = new HostnameVerifier() {
      public boolean verify(String urlHostName, SSLSession session) {
         return true;
   }
   };
   HttpsURLConnection.setDefaultHostnameVerifier(hv);
  } catch (Exception e) {
  }

  HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
  
  try
  {
   con.connect();
   responseCode = con.getResponseCode();
  } 
  catch(Exception e)
  {
   // do nothing here as the exception can occur even when the functionality is proper.
  }
 }

    else
 {
  HttpURLConnection con = (HttpURLConnection) url.openConnection();  
  try
  {
   con.connect();
   responseCode = con.getResponseCode();
  } 
  catch(Exception e)
  {
   // do nothing here as the exception can occur even when the functionality is proper.
  }
 }
 if( responseCode >= 400 )//logggg
 {
  fileName = "/default.jsp";
 }
 else
 {

  //设定指定的路径
  fileName = "/easycrm";  
 }
 response.sendRedirect(fileName);
%>

然后,修改$tomcat/conf/web.xml文件。   
   在web.xml文件中,有一段如下:   
           <welcome-file-list>   
                   <welcome-file>index.html</welcome-file>   
                   <welcome-file>index.htm</welcome-file>   
                   <welcome-file>index.jsp</welcome-file>   
           </welcome-file-list>   
   在<welcome-file-list>与<welcome-file>index.html</welcome-file>之间添加上:   
    
   <welcome-file>a.jsp</welcome-file>   

重启tomcat,访问会自动跳转到webapp下easycrm目录中

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载