Home>
I want to achieve

I am studying jsp by myself,
Is there a way to send the return value of a method to a servlet using jsp?
If there is a method, I would like to know what to use.

As for what I want to do, I want to change the ID that is sent depending on where I press it.

Source code example

For example, if i am making a class like this

public class ID{
    private String id;
//Setter etc. omitted
――
    public String getID(){
        return id;
    }
――

Set the ID list ArrayListlist in the session scope in the servlet, and write it in jsp like this

<%ArrayList<ID>list = (ArrayList<ID>) session.getAttribute("list");%>
// Various omissions
<% for (ID id: list){ %>
<%= id.getID() %><br>
<%} %>


Output result

----ID1----
----ID2----
----ID3----
     .
     .

When this happens,
--When you press ID1--, the value of "ID1" is displayed for the destination servlet.
--When you press ID2--, the value "ID2" is sent to the destination servlet.
I want to do that.