How to pass a value from one jsp to another jsp page?

前端 未结 4 1714
不知归路
不知归路 2020-11-27 06:29

I have two jsp pages: search.jsp and update.jsp.

When I run search.jsp then one value fetches from database and I store that

4条回答
  •  醉梦人生
    2020-11-27 07:28

    Use below code for passing string from one jsp to another jsp

    A.jsp

       <% String userid="Banda";%>
        
    <% session.setAttribute("userId", userid); %>

    B.jsp

        <%String userid = session.getAttribute("userId").toString(); %>
        Hello<%=userid%>
    

提交回复
热议问题