4

How I can set an attribute in a session using expression language in the following code

 <body>
        <h1>Hello ${param.name}!</h1>
        <% String n = $ {param.name} %>

        <%
            session.setAttribute("user", n);
        %>  

        <a href="process.jsp">visit</a>  
    </body>

1 Answer 1

15

By using the following code you can set values to the session variable:

<c:set var="user" value="${param.name}" scope="session" />

To print the session variable:

<c:out value="${sessionScope.user}" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.