Reputation: 821
Before, I normally set and get attributes in session. But lately, one of my session attributes began behaving as if it is null. My team can normally get the specific session attribute using my PC as the host of web application while I myself cannot get. As a short description of my problem, we have the same codes, my team can get values in the session that is run through scriptlets and I cannot. We use tomcat as server, eclipse juno, chrome as browser, and my PC is the only one which encounters this bug. Is there a problem in my machine, browser or some elsewhere?
Code:
<% List<Place> places = (List<Place>) session.getAttribute("places");
for (Place p : places ) { %>
<option value="<%=p.getID()%>"><%=p.getPlaceName()%></option>
<%} %>
The for
loop does execute because as I have said because it does not get a value in the session. I've cleaned my caches and have tried to other browsers but still it behaves like that in my machine...
Upvotes: 0
Views: 87
Reputation: 1648
If you are getting session attributes at one place then you should be able to get at other place also. I do not see why It should not.
request.getSession(false);
there can be synchronization issue. always do session work in a synchronize block.
HttpSessionAttributeListener can be configured to see when attribute was added to your session.
Upvotes: 0
Reputation: 2496
check cookie is enabled in your server not. if cookie is disabled then enable it
Upvotes: 1