GeeCON Prague 2014*
The moose likes JSP and the fly likes jsp session traking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "jsp session traking" Watch "jsp session traking" New topic
Author

jsp session traking

kingshuk paul
Greenhorn

Joined: Dec 05, 2001
Posts: 16
If anybody could ans.Please help me.

Subject.
Suppose in shopping cart i am binding an assembly[object] object by session id[session.putValue(sessionid,Assebly);
or binding by key word like session.putValue("Cart",assebmly);
now if internet exploree tools=>Internet options-->security-->
internet [If i use degfault setting its woking fine retrieving values] but if i go for customise setting and set per session cookies [not stoterd] option disabled.
Every time page chnges the hash code of the session object is
changing means whatever i bind for the first time is not visible 2nd time.Since session object is changed.
Now could anybody kindly tell me how and whre should i bind my carting object so that in any setting it shouild work
in any browser.
Plese weitr the full code.
thanks
kingshuk

kin
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
You shouldn't change your code.
You should change your server configuration
(the servlet/JSP engine) to support session
tracking without cookies. (For Tomcat v4,
you need to set cookies="false" in the
<Context> element within your server.xml
file.
OR
You should leave the cookies enabled in your
browser and require users to leave cookies
enabled.
If you start trying to write code to cover all
the possible settings in all the possible browsers,
you'll be writing code long after you needed to
have it done. And then someone will change the
server and you'll start all over again!
Joe
kingshuk paul
Greenhorn

Joined: Dec 05, 2001
Posts: 16
Originally posted by Joe Gilvary:
You shouldn't change your code.
You should change your server configuration
(the servlet/JSP engine) to support session
tracking without cookies. (For Tomcat v4,
you need to set cookies="false" in the
<Context> element within your server.xml
file.
OR
You should leave the cookies enabled in your
browser and require users to leave cookies
enabled.
If you start trying to write code to cover all
the possible settings in all the possible browsers,
you'll be writing code long after you needed to
have it done. And then someone will change the
server and you'll start all over again!
Joe

kingshuk here
=================

Ok fine .As you said i should configure in tomcats[v4] server.xml
cookies="false".But what about the other server And suppose i host a site where i dont have the control over setting server configuration.Then what am i supposted to do?
My web-hosting company is running resin-2.0.2 ,a
good server.So in that what can i do in the server side for all kind of session tracking support.
If i leave it to the user to set cookies then i have to display message for typical setting.Is'nt it .For diff browser how do i maintain it?
Could you kindly explin in more details.Like in IE
i gave an examples.For netscape all versions,Mozilla or other
browser what am i supposed to do.
please kindly guiide me.
thanks a lot
Joe Gilvary
kingshuk

Pat Wallwork
Ranch Hand

Joined: Sep 23, 2001
Posts: 72
kingshuk,
If you just make use of encodeURL() and encodeRedirectURL() you won't have to worry about it. All links to pages that use the session should be written like this:
<a href="<%= response.encodeURL("your URL") %>">
Then the session API first tries to use cookies, but if it's disabled it appends the URL with the sessionID.
Pat
prabhat gupta
Greenhorn

Joined: Aug 21, 2001
Posts: 26
Hi,
I want to generate a number of rectangular boxes with text in each box just like flowcharts.I havent tried anuthing on this but just have the concept in mind.I want to generate it on the fly using jsp pages.For this i need to draw the image on to a virtual awt.Panel object.I am using the GifEncoder API provided by acme which encodes the drawn objects to a gif image and sends to the client.this concept is mentioned by Jason Hunter in his book "Java Servlet programming".
My problem here is that since i want to use the same API from jsp pages and the Api needs to call a method and send the output stream object to it to print the image to the client.now jsp has a out object which is a PrintWriter object.so how can i pass the ServletOutputStream object to it.
The method is :
ServletOutputStream out = res.getOutputStream();
GifEncoder encoder = new GifEncoder(image,out);
kingshuk paul
Greenhorn

Joined: Dec 05, 2001
Posts: 16
Originally posted by Pat Wallwork:
kingshuk,
If you just make use of encodeURL() and encodeRedirectURL() you won't have to worry about it. All links to pages that use the session should be written like this:
<a href="<%= response.encodeURL("your URL") %>">
Then the session API first tries to use cookies, but if it's disabled it appends the URL with the sessionID.
Pat

Hi
Pat Wallwork
Thaknks for replying.But you did not get the exact problem.My question is suppose someonte in IE (take) goes to tools->InternetOptions->Security->internet->Custom levels->Allow per session cookie [not stored] and then disable the choice.
In that case each time i go for get or post or
change the page my session object itself is chaging means the hashcode itself chaging.That means for each req. it creates new session object not for entire browser
openning.
In this case even i append the sessionid with the query.First time i may bind my object(cart) with seessionid but in next request i wont find it since the session object itself has changed.
Could you kindly elaborate in this matter.If ppossible just write the code.And any server cofiguration req so that the shopping cart runs in any condition.I am using resin-2.0.2 server
thanking you
kingshuk
 
GeeCON Prague 2014
 
subject: jsp session traking