Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where does PageContext store the info?

 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i understand from this code is as follows:

i add an object to the session scope of page context. the jsp engine creates a unique id and stores the object and id on server in a hashtable or smtn. it also stores a cookie containing this id, on the client IE.

the problem is that when i disabled all cookies in my IE , this code still works. but i havent used any encodeURL here, then why does it work?

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

<%@page contentType="text/html" %>

<%!
/* functions come here */
%>

<%
/* code comes here */

StringBuffer htmlBuffer = new StringBuffer();
Integer i1 = new Integer(10);
pageContext.setAttribute("integer",i1,PageContext.SESSION_SCOPE);
Integer i2 = (Integer)pageContext.getAttribute("integer",PageContext.SESSION_SCOPE);
htmlBuffer.append(i2.toString());


%>

<html>

<body>

<%= htmlBuffer.toString() %>

<h1>Hello World JSP</h1>
<a href="test2.jsp">next page</a>
</body>

</html>

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

<%@page contentType="text/html" %>

<%!
/* functions come here */
%>

<%
/* code comes here */

StringBuffer htmlBuffer = new StringBuffer();
Integer i1 = (Integer)pageContext.getAttribute("integer",PageContext.SESSION_SCOPE);
if(i1 == null)
{
htmlBuffer.append("session does not exist.");
}
else
{
htmlBuffer.append(i1.toString()+" is the value.");
}


%>

<html>

<body>

<h3><%= htmlBuffer.toString() %></h3>

</body>

</html>
------------------------------------------
 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
someone plz answer!!!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two types of cookies. MSIE has a separate switch for session cookies.
It's in the 'Advanced Privacy' section.
 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ur response was so curt, i cudnt make anyting out of it!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you disabled cookies but not "session cookies" then JSP sessions will continue to work without URL re-writing.

Look at -> tools -> internet options -> privacy (tab) -> advanced (button).
There is a checkbox labled "always allow session cookies".

Check that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic