2016-09-14 3 views
0

나는 거기에 코드를 다음의 login.jsp를 구부려 썼다 - 나는 otpText 내부의 값을 입력하고 내가 양식을 제출하면 그 값이 URL에 표시됩니다매개 변수 값이 null로 표시되는 이유는 무엇입니까?

<script> 

    function a(){ 
    var otp=document.getElementById("otpText").value; 
    document.location.href="?otp="+otp; 
    <% System.out.println(request.getParameter("otp")); %> //printing null 
    return false; 
    } 

    </script> 

    <form name="otp" method="post" action="" > 
    Enter otp: 
    <input type="text" name="otpText" id="otpText"/> 
    <input type="submit" value="Submit" onClick="return a()"/> 
    </form> 

. 그러나 위의 코드 에서처럼이 값을 인쇄 할 때 null이 인쇄됩니다. 그 값을 session.Please에 저장할 때 어떤 도움을 주시면 감사하겠습니다. 당신이

var otp=document.getElementById("otpText").value; 
console.log (otp); // or alert (otp); 
document.location.href="?otp="+otp; 

에 코드를 변경하는 경우

+0

요청이 전송 된 매개 변수를 인쇄합니다. request.getParameter() 요청을 보낸 후 작동 – Jens

답변

0

당신은 값을 볼 수 있습니다.

+0

어떻게 세션에 저장할 수 있습니까 ?? –

+1

세션은 서버 측의 제어입니다. 실제로 서블릿을 호출하는 경우 추가 할 수 있습니다. –

관련 문제