• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in Session parameters

 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we assign a session variable to a form property

Suppose I have a session variable named "username"........I do the following:


<%
String user=(String) session.getAttribute("username");
if(user==null) user="";
%>

Now can I write:


<jsp:setProperty name="details" property= "*" />

<jsp:setProperty name="details" property="id" value="user" />


If no, then how can I use the session parameter as a form parameter?
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use expression in the value attribute of set property, it's allowed

Try


 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.........I don't know whether it worked or not because when I am sending the value to the java file I still get the same result as follows:
false ACCOUNT NUMBER: 5456
ACCOUNT TYPE:null
USERNAME:null
ID:
BALANCE:null

here are the codes:

viewuserdetails.jsp




detailsproperties.jsp



viewaccountbalance.java

I would be grateful if someone could point out my mistake

Please tell me whether the JSP programs are right and whether the values enter the java file because I have separately run the java file in IDE using specific values and it worked just fine

I am now sure that the value is not entering the java program because I am getting Resultset exhausted
 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getting exhausted result set when using <jsp:setProperty name="details" property="id" value="${sessionScope.user}" />
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does a result set have to do with your session?
 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done it.......thanks to everyone who helped!!! Actually the problem was that the session parameter was not being recognized by the bean form..........so I tried the other way round.............I did not use:




What I did was that pass the session parameter as an argument to the Java file and got the result

The problem why I got the resultSet exhausted was that the Java program was not able to recognize one of the parameters and taking it as null for which I was basically getting:




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic