2017-07-19 11 views

答えて

0

試してみてください。

the request Scope name is : <%=pageContext.getAttribute("requestScope")%> 
the sessionScope name is : <%=pageContext.getAttribute("sessionScope")%> 
the appication Scope name is : <%=pageContext.getAttribute("applicationScope")%> 

へ:

<% 

    String username =request.getParameter("name"); 
    if(username!=null){ 
     //session.setAttribute("sessionUsername", username); 
     //application.setAttribute("appUsername", username); 
     pageContext.setAttribute("requestParams",username); 
     pageContext.setAttribute("requestScope", username, PageContext.REQUEST_SCOPE); 
     pageContext.setAttribute("sessionScope", username, PageContext.SESSION_SCOPE); 
     pageContext.setAttribute("applicationScope", username, PageContext.APPLICATION_SCOPE); 
    } 
    /* String sessionName =(String)session.getAttribute("sessionUsername"); 

    String applicaString = (String)application.getAttribute("appUsername"); 
    */ 
    %> 
<%-- <br> 
the name is : <%=username%> 
<br> 
the session name is : <%=sessionName%> 
<br> 
the application name is : <%=applicaString%> 
--%> 
<br> 
the request Scope name is : <%=request.getAttribute("requestScope")%> 

<br> 
the sessionScope name is : <%=session.getAttribute("sessionScope")%> 

<br> 
the appication Scope name is : <%=application.getAttribute("applicationScope")%> 

<br> 
the page Scope name is : <%=pageContext.getAttribute("requestParams")%> 

私はあなたからの次の3行のコードを変更し

the request Scope name is : <%=request.getAttribute("requestScope")%> 
the sessionScope name is : <%=session.getAttribute("sessionScope")%> 
the appication Scope name is : <%=application.getAttribute("applicationScope")%> 
+0

感謝!!出来た 。 –

+0

別のソリューションでは、次のコードを使用しています。<%= pageContext.getAttribute( "requestScope" ,, PageContext.REQUEST_SCOPE)%> sessionScopeの名前は次のとおりです:<%= pageContext.getAttribute( "sessionScope"、PageContext.SESSION_SCOPE)%> appicationスコープ名は次のとおりです。<%= pageContext.getAttribute( "applicationScope"、PageContext.APPLICATION_SCOPE)%> –

関連する問題