0

I want to keep jstl value(dynamic) in the session. How can I do? For example my code segment is : (userid is session attribute that is assigned previous page when student login the system)

<sql:setDataSource
        var="myDS"
        driver="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/loginuser"
        user="root" password="root2"
    />

    <sql:query var="listUsers"   dataSource="${myDS}">
        SELECT name FROM course_student where id = ?;
        <sql:param value="${userid}" />
    </sql:query>



    <div align="center">
        <table width= "23%" border="1" cellpadding="5">

            <tr>
                <th>Your courses</th>

            </tr>
            <c:forEach var="x" items="${listUsers.rows}">
                <tr>
                    <td><a href=student_course.jsp> <c:out value="${x.name}" /></a></td>


                </tr>
            </c:forEach>
        </table>
    </div>

I didn't share all the code because it is long and can be complicated for you. I will explain code. It is a student-course system.Here, firstly I connect to database, then I bring his/her courses dynamically from database.

  <td><a href=student_course.jsp> <c:out value="${x.name}" /></a></td>

here x.name bring all links(courses). For example; computer organization, database systems, object oriented programming I want to keep these variables in session WHEN LINK IS CLICKED! Which link was clicked by the user, its name should be stored in the session. Then I can handle in the new page according to this session variable.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Gürkan Çatak
  • 923
  • 1
  • 9
  • 17
  • Just use a servlet the usual way? JSTL SQL taglib is for quick prototyping only and absolutely not for real world applications. See also http://stackoverflow.com/tags/jstl/info – BalusC Mar 08 '16 at 12:23
  • How can I use servlet? I couldn't bring dynamic data by using jsp. I need to use jstl for dynamic data. Additionally, I need to combine jsp with jstl in this case. I am confused. – Gürkan Çatak Mar 08 '16 at 12:56
  • http://stackoverflow.com/q/5003142 – BalusC Mar 08 '16 at 12:56

1 Answers1

0

I solved, I used get method to connect two pages. This line was changed.

 <td align="center"><a href="studentcoursepage.jsp?value1=${x.name}" target="_new"> <c:out value="${x.name}" /></a></td> 

In the next jsp page I called request.getParameter("value1") Then I can reach which link is clicked.

Gürkan Çatak
  • 923
  • 1
  • 9
  • 17