Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在子jsp中获取java对象_Java_Jsp_Object_Parent Child_Parent - Fatal编程技术网

如何在子jsp中获取java对象

如何在子jsp中获取java对象,java,jsp,object,parent-child,parent,Java,Jsp,Object,Parent Child,Parent,我有两个JSP init.jsp second.jsp init.jsp PreferenceServices preferenceServices = PreferenceServices.getUserSpecificPreferences(renderRequest); 这里PreferenceServices是一个类,getUserSpecificPreferences(renderRequest)是PreferenceServices类的静态方法 second.jsp <%@

我有两个JSP

  • init.jsp
  • second.jsp
  • init.jsp

    PreferenceServices preferenceServices = PreferenceServices.getUserSpecificPreferences(renderRequest);
    
    这里PreferenceServices是一个类,
    getUserSpecificPreferences(renderRequest)
    PreferenceServices
    类的静态方法

    second.jsp

    <%@ include file="/init.jsp"%>
    long documentId = Long.parseLong(preferenceServices.getValue(Constant.DOCUMENT_PREFERENCE, "0"));
    
    
    long documentId=long.parseLong(preferenceServices.getValue(Constant.DOCUMENT_PREFERENCE,“0”);
    
    这里preferenceServices是在init.jsp中定义的
    getValue(string,string)
    PreferenceServices
    类的一种方法

    现在问题是,, 我无法使用second.jsp的上述代码行在second.jsp中获取值

    <%@ include file="/init.jsp"%>
    long documentId = Long.parseLong(preferenceServices.getValue(Constant.DOCUMENT_PREFERENCE, "0"));
    
    有谁能告诉我怎么解决这个问题吗

    谢谢


    Ravi Darji

    您可以在请求中存储您的值:

    <%
    request.setAttribute("documentId",documentId);
    %>
    
    
    
    然后,您将在second.jsp中检索以下内容:

     <% documentId = request.getAttribute("documentId");%>
    
    
    
    用途包括行动:

    <jsp:include page="init.jsp" />
    
    
    
    何时使用包含操作

    Include标记不将包含页面的源代码包含到当前页面中,而是将包含页面在运行时生成的输出包含到当前页面响应中。
    您可以在请求中存储您的值:

    <%
    request.setAttribute("documentId",documentId);
    %>
    
    
    
    然后,您将在second.jsp中检索以下内容:

     <% documentId = request.getAttribute("documentId");%>
    
    
    
    用途包括行动:

    <jsp:include page="init.jsp" />
    
    
    
    何时使用包含操作

    Include标记不将包含页面的源代码包含到当前页面中,而是将包含页面在运行时生成的输出包含到当前页面响应中。

    您能解决这个问题吗?您能解决这个问题吗?