Reaches values ​​between two jsp with jstl

I am creating two jsp pages with jstl and I want to get data from the first page to the second.

On my first page I have

<c:out value="${cursor.getId_node() }"></c:out><br>

and I want this variable on my second page.

How can i do this?

thank

-1
source share
2 answers

Here is a sample code to access the value between two jsp with jstl.

First JSP

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
  <body>
    This JSP stores the 'para' in a session-scoped variable where
    the other JSPs in the web application can access it.
    <p />
    <c:set var="para" value="${41+1}" scope="session"  />

     Click <a href="displayAttributes.jsp">here</a> to view it.
  </body>
</html>

Second JSP (displayAttributes.jsp)

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
  <head>
    <title>Retrieval of attributes</title>
  </head>
  <body>
    The para is <c:out value="${sessionScope.para}" /> <br/>
  </body>
</html>

Set the attribute in the session area

<c:set var="para" value="${41+1}" scope="session"  />

Get Attribute from Session Area

<c:out value="${sessionScope.para}" />

More samples in other areas.

    <%-- Set scoped variables --%>
    <c:set var="para" value="${41+1}" scope="page" />
    <c:set var="para" value="${41+1}" scope="request" />
    <c:set var="para" value="${41+1}" scope="session" />
    <c:set var="para" value="${41+1}" scope="application" />

    <%-- Print the values --%>
    <c:out value="${pageScope.para}" />
    <c:out value="${requestScope.para}" />
    <c:out value="${sessionScope.para}" />
    <c:out value="${applicationScope.para}" />
+1
source

you can put the area value(cursor.getId_node())in 'request'and in the second jsp, get the value from the request

+1
source

Source: https://habr.com/ru/post/1540909/


All Articles