Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Session attribute using expression language

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>
like image 251
mohsen.nour Avatar asked Dec 09 '22 04:12

mohsen.nour


1 Answers

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}" />
like image 65
vjy Avatar answered Dec 28 '22 08:12

vjy