2014-08-27 2 views
1

오프라인 양식 (자바 스크립트를 사용하여 제출 된 HTML 양식)을 제출할 GateIn 포털 기반 애플리케이션이 있습니다.요청을 제출할 수 없습니다. GateIn 포털의 IE에서

내 양식을 게시 할 때 Servlet에 제출하십시오. Servlet은 사용자가 로그인했는지 확인합니다. 사용자가 기록되지 않은 경우 사용자를 로그인 페이지로 리디렉션하고 양식 데이터를 구문 분석하여 세션에 저장하고 로그인 페이지를 표시합니다. 로그인 페이지에서 사용자가 자격 증명을 입력하고 제출하십시오. 로그인 포틀릿에서 저장된 세션 데이터를 사용할 수 없습니다.

동일한 작업이 mozilla에서 작동합니다. 리디렉션 페이지를 로그인하는 곳에서

Servlet이 구성됩니다

protected void doPost(HttpServletRequest aoRequest, HttpServletResponse aoResponse) throws ServletException, IOException 
{ 
    MOLOGWRAPPER.info("SPEFormServiceServlet doPost start"); 
    Map<String, Object> loHMForm = null; 
    String lsIsOffline = null; 
    String lsServiceName = null; 
    String lsApplicantId = null; 
    lsIsOffline = (String) aoRequest.getParameter("Offline"); 
    String lsTimeStamp = null; 
    long loTimeStamp; 
    String lsContentPath = this.getServletConfig().getServletContext().getRealPath(""); 
    if (null != aoRequest.getParameter("formAction") && "fromLogin".equalsIgnoreCase(aoRequest.getParameter("formAction"))) 
    { 
    loHMForm = (Map<String, Object>) aoRequest.getSession().getAttribute("OfflineData"); 
    } 
    //MOLOGWRAPPER.info("LoHM after login in servlet "+loHMForm); 
    String msUserId = null; 
    if (null != aoRequest.getUserPrincipal()) 
    msUserId = aoRequest.getUserPrincipal().getName(); 
    HttpSession moSession = aoRequest.getSession(); 
    try 
    { 
    if (null != aoRequest.getParameter("serviceName")) 
    { 
     lsServiceName = aoRequest.getParameter("serviceName").trim(); 
    } 
    lsApplicantId = aoRequest.getParameter("applicantId"); 
    // Getting unique time stamp for per user per service 
    if (null != aoRequest.getParameter("timestamp")) 
    { 
     lsTimeStamp = aoRequest.getParameter("timestamp").trim(); 
     loTimeStamp = Long.parseLong(aoRequest.getParameter("timestamp")); 
    } else 
    { 
     loTimeStamp = (new Date()).getTime(); 
     lsTimeStamp = String.valueOf(loTimeStamp); 
     aoRequest.setAttribute("TMAttachment", lsTimeStamp); 
    } 
    if (null != lsIsOffline && lsIsOffline.equals("Y")) 
    { 
     if (null == msUserId) 
     { 
     try 
     { 
      MOLOGWRAPPER.info("SPEFormServiceServlet in logout block msUserId:" + msUserId); 
      MOLOGWRAPPER.info("SPEFormServiceServlet in logout block SessionID:" + aoRequest.getSession().getId()); 
      aoRequest.logout(); 
     } catch (ServletException e) 
     { 
      e.printStackTrace(); 
     } 
     aoRequest.getSession().setAttribute("OfflineData", loHMForm); 
     aoRequest.setAttribute("OfflineData", loHMForm); 
     aoResponse.sendRedirect(aoRequest.getScheme() + "://" + aoRequest.getServerName() + ":" + aoRequest.getServerPort() + "/portal/portal/Login?offlineFlag=y&FromForm=y&sp_serviceName=" + lsServiceName); 
     return; 
     } 
    } 
    } catch (Exception e) 
    { 

    } 
} 

로그인 포틀릿 :

  • doView :
public void doView(RenderRequest aoRequest, RenderResponse aoResponse) 
    throws PortletException, IOException 
{ 

    RenderRequestImpl renderRequest = (RenderRequestImpl) aoRequest; 
    HttpServletRequestWrapper httpReq = renderRequest.getRealRequest(); 
    String serviceName = httpReq.getParameter("sp_serviceName"); 
    aoRequest.setAttribute("sp_serviceName", serviceName); 
    String offlineFlag = httpReq.getParameter("offlineFlag"); 
    aoRequest.setAttribute("sp_offlineFlag", offlineFlag); 
    String fromFrom = httpReq.getParameter("FromForm"); 
    aoRequest.setAttribute("FromForm", fromFrom); 

    PortletSession moSession = aoRequest.getPortletSession(); 

    if (null != httpReq.getParameter("FromForm") && "Y".equalsIgnoreCase(fromFrom)) 
    { 
    moSession.setAttribute("OfflineData", 
     httpReq.getSession().getAttribute("OfflineData"), 
     PortletSession.APPLICATION_SCOPE); 
    } 

    lscsrfVal = RandomStringUtils.randomAlphanumeric(40); 
    moSession.setAttribute("csrfVal", lscsrfVal); 
    aoRequest.setAttribute("csrfVal", lscsrfVal); 
    logger.info("lscsrfVal :: " + lscsrfVal); 
    logger.info("moSession : Doview id :: " + moSession.getId()); 
} 
  • .210 :
public void processAction(ActionRequest aoRequest, ActionResponse aoResponse) 
    throws PortletException 
{ 

    PortletSession moSession = aoRequest.getPortletSession(); 
    logger.info("moSession : Process Action id :: " + moSession.getId()); 
    logger.info("csrfVal == " + moSession.getAttribute("csrfVal")); 
    HttpServletRequest req = Util.getPortalRequestContext().getRequest(); 
    HttpSession moHttpSession = req.getSession(); 
    moHttpSession.getAttribute("csrfVal"); 
    logger.info("moHttpSession : Process Action id :: " + moHttpSession.getId()); 
    logger.info("moHttpSession : Process Action OfflineData ::" 
     + moHttpSession.getAttribute("OfflineData")); 

    if (null != moSession.getAttribute("csrfVal") 
     && null != aoRequest.getParameter("sp_csrf") 
     && aoRequest.getParameter("sp_csrf").equals(moSession.getAttribute("csrfVal"))) 
    { 
    logger.info("request is valid"); 
    moSession.removeAttribute("csrfVal"); 
    } else 
    { 
    moSession.setAttribute("csrfValErr", "true"); 
    logger.info("request is invalid :: Redirect to Login"); 
    return; 
    } 
} 

로그 : HttpServletRequest의 httpReq = Util.getPortalRequestContext()와

15:37:41,387 INFO [com.abc.sp.action.SPEFormServiceServlet] (ajp-/127.0.0.1:8009-1) SPEFormServiceServlet in logout block msUserId:null 
15:37:41,387 INFO [com.abc.sp.action.SPEFormServiceServlet] (ajp-/127.0.0.1:8009-1) SPEFormServiceServlet in logout block SessionID:k4dIpdc1Dqiadh4ZMCGTQaeN 

15:37:44,418 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) SPUserActionPortlet : doView : start 
15:37:45,287 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) lscsrfVal :: PLlmfohMhtPBkO2Qt7HAQAMQsdaAg5qsEWCII8aP 
15:37:45,287 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) moSession : Doview id :: NC9VLsKmqKPuev2AA304RMTU 
15:37:45,287 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) SPUserActionPortlet : doView : end 

15:38:07,471 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) SPUserActionPortlet : processAction : Start 
15:38:07,491 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) moSession : Process Action id :: o8t09QtNv7-fpR0hcP7uXs1g 
15:38:07,491 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) csrfVal == null 
15:38:07,491 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) moHttpSession : Process Action id :: o8t09QtNv7-fpR0hcP7uXs1g 
15:38:07,491 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) moHttpSession : Process Action OfflineData :: null 
15:38:07,491 INFO [com.abc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-1) request is invalid :: Redirect to Login     

EDIT

하는 doView 방법 대해 GetRequest();

public void doView(RenderRequest aoRequest, RenderResponse aoResponse) 
      throws PortletException, IOException { 
     HttpServletRequest httpReq=Util.getPortalRequestContext().getRequest(); 
     HttpSession moHttpSession =httpReq.getSession(); 
     String serviceName=httpReq.getParameter("sp_serviceName"); 
     aoRequest.setAttribute("sp_serviceName", serviceName); 
     String offlineFlag=httpReq.getParameter("offlineFlag"); 
     aoRequest.setAttribute("sp_offlineFlag", offlineFlag); 
     String fromFrom=httpReq.getParameter("FromForm"); 
     aoRequest.setAttribute("FromForm", fromFrom); 
     PortletSession moSession = aoRequest.getPortletSession(); 
     if(null!=httpReq.getParameter("FromForm") && "Y".equalsIgnoreCase(fromFrom)){ 
      moSession.setAttribute("OfflineData", httpReq.getSession().getAttribute("OfflineData"), PortletSession.APPLICATION_SCOPE); 
     } 

     lscsrfVal = RandomStringUtils.randomAlphanumeric(40); 
     moSession.setAttribute("csrfVal",lscsrfVal); 
     aoRequest.setAttribute("csrfVal",lscsrfVal); 
     MOLOGWRAPPER.info("lscsrfVal :: "+lscsrfVal); 
     MOLOGWRAPPER.info("moSession : Doview id :: "+moSession.getId()); 

    } 

로그 :

11:56:05,636 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-2) SPUserActionPortlet : doView : start 
11:56:05,637 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-2) lscsrfVal :: TsUGvRcevcuSeo4a7daqhl2bjU6lJf9Cg6MNLgYn 
11:56:05,637 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-2) moSession : Doview id :: 7jxf2nzyatjdxYgoMYYGHKyj 
11:56:05,637 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-2) SPUserActionPortlet : doView : end 

로그 :하는 doView에서의 processAction에서 :

11:56:37,526 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-5) moSession : Process Action id :: -r96FXye5MlDW+xsEjUgKbzV 
11:56:37,527 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-5) csrfVal == null 
11:56:37,527 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-5) moHttpSession : Process Action id :: -r96FXye5MlDW+xsEjUgKbzV 
11:56:37,528 INFO [com.acc.sp.action.SPUserActionPortlet] (ajp-/127.0.0.1:8009-5) moHttpSession : Process Action OfflineData :: null 

답변

0

포틀릿 사양 (JSR-168 및 JSR-286) 포틀릿 기간을 명시하고, 아래처럼 흘러야합니다 :

init -> processAction -> render -> dest 포털 용기가 공정 포탈 뷰 모드 렌더링 화재시 로이

doView 메소드가 실행된다. 따라서이 메서드는 processAction 메서드 뒤에 호출됩니다. 그래서 휠을 뒤집어서 이 아닌 processAction 방법으로 세션 속성을 설정하십시오.

+0

포틀릿은 사용자의 로그인 페이지에 있으므로 doView가 먼저 호출됩니다. processAction을 직접 호출 할 수있는 방법은 없습니다. processAction은 사용자가 해당 포틀릿에 대한 작업을 수행하면 호출됩니다. 또한 참조하십시오 - http://stackoverflow.com/questions/11330969/understanding-the-execution-of-action-phase-and-render-phase – Ankit

+0

당신은 당신의 작전에 그것을 지적해야합니다. 그런데 로그인 리디렉션 서블릿에서 whay가'aoRequest'입니까? 모든 코드에 메서드 시그니처를 제공 할 수 있습니까? – tmarwen

+0

aoRequest는 Servlet 클래스의 HttpServletRequest, doView 메소드의 RenderRequest 및 login 포틀릿 클래스의 processAction 메소드의 ActionRequest입니다. – Yogesh

관련 문제