2012-05-04 22 views
0

我有一個登錄servlet,它從我的登錄頁面上的表單(通過POST)接收用戶名和密碼。 一旦通過驗證,我正在嘗試導航到歡迎頁面。但問題是,我的代碼在IE8上正常工作,但在Firefox和Chrome上它只顯示一個空白頁面。 如果我點擊查看源代碼,正確的HTML是有,但實際上沒有任何顯示。 如果我直接從地址欄請求歡迎頁它無論是在FF和鉻正確顯示。轉發請求從servlet到jsp在firefox中提供空白頁面

發佈我下面的代碼,請指教任何更改/最佳做法,必要時...這是所有新的給我。

登錄的Servlet

public class Login extends HttpServlet { 
     public static String jsessionid = null; 

     public void doGet(HttpServletRequest req, HttpServletResponse resp) 
      throws ServletException, IOException { 
     System.out.println("GET CALLED"); 
     doPost(req, resp); 
    } 

    public void doPost(HttpServletRequest req, HttpServletResponse resp) 
      throws IOException, ServletException { 
     System.out.println("POST CALLED"); 
     String username = req.getParameter("username"); 
     String password = req.getParameter("password"); 

     String jsessionid_full; 
     String endpoint = "https://sample-url"; 
     try { 
      // Authentication Code... 
        // Authentication Code... 

      // resp.sendRedirect(resp.encodeRedirectURL("welcome.jsp")); 

      String nextJSP = "welcome.jsp"; 
      RequestDispatcher dispatcher = getServletContext() 
        .getRequestDispatcher(nextJSP); 
      dispatcher.forward(req, resp); 

     } catch (Exception e) { 
      System.out.println(e); 
     } 

    } 
} 

的welcome.jsp頁面目前只是一些靜態文本

的web.xml是...

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>mobile CRM</display-name> 
    <servlet> 
    <servlet-name>Login</servlet-name> 
    <servlet-class>crmApp.Login</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>Login</servlet-name> 
    <url-pattern>/Login</url-pattern> 
    </servlet-mapping> 
    <servlet> 
    <servlet-name>AccountQuery</servlet-name> 
    <servlet-class>crmApp.AccountQuery</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>AccountQuery</servlet-name> 
    <url-pattern>/AccountQuery</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
    <welcome-file>login.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

我身份驗證程序正常工作...它唯一的顯示在FF和Chrome中有問題的歡迎頁面。

另外執行後,在地址欄中的URL是登錄的servlet即/登錄

任何響應,將不勝感激。 謝謝

+0

你不必擔心你使用的瀏覽器。 – Swapnil

回答

0

我不知道爲什麼你在不同的瀏覽器中看到不同的行爲,因爲它是webapp的內部轉發,但嘗試重定向用戶而不是轉發;這會導致地址欄中的網址也發生更改。

下面是一些關於這個問題good info

0

看看HTTP頭回來。有一些很好的FF插件來顯示這些如直播HTTP頭

比較來自與登錄請​​求轉發到那些你直接的歡迎頁面請求重新調校的頭。

0

對不起...問題顯然是在我的樣式表 在這裏使用jQuery和jQuerymobile ...瀏覽器問題!

相關問題