Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the session values into another jsp's

 
lokesh pushpa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have one DropDown box in One jsp, it is having some accounts. When ever user selects the account it will show some transactions on that account.
Now my requirement is : i have get that "Account name" (which is selected by user) into another jsp.
So i have to put that dyanamic value into session and get that value into another jsp.
How to use the session in jsp and how to set the value into session and how to get that value into another jsp.

Please guide me on this requirement.

Sorry for my bad english....

Thanks
Lokeshpushpa

 
lokesh pushpa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:set var="names" scope="session" value="${filegen.name}"/>
<cut value="${names}"/> <%-- Output: names--%>



(OR)

<%= session.getAttribute("names") %> <%-- Output: value of user name--%>
<% String user = session.getAttribute("names"); %>
<c:remove var="names" scope="session"/>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never use Java scriptlets in a JSP.

You should store the value in the session in the controller that obtains the value. Then you can simply use the EL to fetch the value.

For example: in the controller: session.setAttribute("accountName",variableWithAccountName);

In the JSP: ${accountName}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic