Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Problem

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried the following coding for understanding the Session.

Servlet1.java
-------------
It is the form that having two fields 'name' and 'password'. When I submitted, it should go to servlet2.java with (Welcome name) and that screen will have another two fields 'age' and 'designation'. When I submitted this one, all the fields(name,password,age,designation) that are entered in the two forms should be displayed in the servlet3.java.

But it returning as Null for all the fields. If I am getting using request.getParameter("name"), it's working. but using session.getAttribute("name" is not working, returing null.

Below is my coding:




 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code does a session.setattribute("Name"...) but gets the value using sess.getAttribute("user"). The key used used in the set and get operation is different.
Replace sess.getAttribute("user") with sess.getAttribute("Name").
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic