Not getting session value????

My code below always shows the "nfsu2SelectedPlatform" as being nulll?  If I check after the conditionals, it is set but when I reload the page, it is null again???? What am I doing wrong???

------------------------------------------------------------------------------------

<%
    HttpSession sessionObject = request.getSession(true);
    String nfsu2SelectedPlatform = (String)sessionObject.getValue("nfsu2SelectedPlatform");
      String platform = request.getParameter("platform");
      
        %>nfsu2SelectedPlatform will be null here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%

      if (nfsu2SelectedPlatform == null) {
        request.setAttribute("nfsu2SelectedPlatform", "ps2");
            platform ="ps2";
      } else if ((!(nfsu2SelectedPlatform.equals(platform)))&&(!(platform.equals("null")))){
            request.setAttribute("nfsu2SelectedPlatform", platform);
            platform = nfsu2SelectedPlatform;
    } else {
            platform = "test";
    }

%>nfsu2SelectedPlatform will be VALID here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%
      
%>
894359Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

894359Author Commented:
FYI.. I have also tried changing " request.setAttribute" to "sessionObject.setAttribute" !
0
objectsCommented:
does your request include nfsu2SelectedPlatform?
what does your form look like?  It needs to contain an attribute named nfsu2SelectedPlatform

0
894359Author Commented:
Or if this makes it easier to read:

------------------------------
<%
    HttpSession sessionObject = request.getSession(true);
    String nfsu2SelectedPlatform = (String)sessionObject.getValue("nfsu2SelectedPlatform");
     String platform = request.getParameter("platform");
      
       %>nfsu2Selected value NOT valid here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%
     
    request.setAttribute("nfsu2SelectedPlatform", "ps2");
         

%>nfsu2Selected value valid here: <%=request.getAttribute("nfsu2SelectedPlatform")%>
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

objectsCommented:
Looks like your request simply does not include an attribute named 'nfsu2SelectedPlatform'.

The sessions does not appear to have anything to do with it as the following line is displaying the value from the request and *not* the session.

     %>nfsu2Selected value NOT valid here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%

Are you sure that shouldn't be:

     %>nfsu2Selected value NOT valid here: <%= nfsu2SelectedPlatform %> <%


0
894359Author Commented:
Please clarify something for me, how do I write to the session and get from the session then???
0
objectsCommented:
to add ad attribute to the session yopu use:
   session.setAttribute(name, value)
to get an attribute from session you use:
   session.getAttribute(name)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
somasekharCommented:
<%
    HttpSession sessionObject = request.getSession(true);
    String nfsu2SelectedPlatform = (String)sessionObject.getAttribute("nfsu2SelectedPlatform");
     String platform = request.getParameter("platform");
     
        %>nfsu2SelectedPlatform will be always null here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%
nfsu2SelectedPlatform will be null here firs time : <%=sessionObject.getAttribute("nfsu2SelectedPlatform")%>

     if (nfsu2SelectedPlatform == null) {
        request.setAttribute("nfsu2SelectedPlatform", "ps2");
sessionObject.setAttribute("nfsu2SelectedPlatform", "ps2");
          platform ="ps2";
     } else if ((!(nfsu2SelectedPlatform.equals(platform)))&&(!(platform.equals("null")))){
          request.setAttribute("nfsu2SelectedPlatform", platform);
          platform = nfsu2SelectedPlatform;
    } else {
          platform = "test";
    }

%>nfsu2SelectedPlatform will be VALID here: <%=request.getAttribute("nfsu2SelectedPlatform")%> <%
     
%>
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.