aspose file tools*
The moose likes JSP and the fly likes doubt in Session parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "doubt in Session parameters" Watch "doubt in Session parameters" New topic
Author

doubt in Session parameters

Agnit Chatterjee
Greenhorn

Joined: Mar 04, 2011
Posts: 24
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

Joined: Aug 29, 2007
Posts: 212

You can use expression in the value attribute of set property, it's allowed

Try



[Servlet tutorial] [Servlet 3.0 Cook Book]
Agnit Chatterjee
Greenhorn

Joined: Mar 04, 2011
Posts: 24
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

Joined: Mar 04, 2011
Posts: 24
getting exhausted result set when using <jsp:setProperty name="details" property="id" value="${sessionScope.user}" />
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

What does a result set have to do with your session?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Agnit Chatterjee
Greenhorn

Joined: Mar 04, 2011
Posts: 24
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:




 
Consider Paul's rocket mass heater.
 
subject: doubt in Session parameters