• Post Reply Bookmark Topic Watch Topic
  • New Topic

session problem

 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i write in
a.jsp page
String s1="amrita";
session.setAttribute("ana",s1);

after some statements

i write


out.print=(String)session.getAttribute("ana") //it prints the value

in page b. jsp

out.print=(String)session.getAttribute("ana") //it prints null
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would add the following to both of your JSPs

<%=session.getId()%>


This will print out the session ID.

If it's different with each request, either sessions are disabled in your container, the timeout is set to a very low value, or your browser is configured not to store session cookie data.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it shows value of session ana in a. jsp page

means browser is enabled to store session data
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both Page A and page B show the same session ID?
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
means
now what can i do?
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone please reply me how can i solve this problem
 
Nicola Garofalo
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put down some real code please.
Your line

shouldn't event compile.

 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the output of

On both the jsp pages?
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't use regional language.
This site is being accessed from all over the world and all of the people can not understand your regional language.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session.getId() shows different session id
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at sam etime i not getting both page values
when i want to get sessionId value from a.jsp i wrote
out.print(session.getId());
response.sendRedirect("b.jsp");


it go to page b.jsp without showing anyvalue that i wrote in out.print("")
 
Gireesh Giri
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure, but check did you disabled the session value in page directive of b.jsp
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your browser's cookie settings to make sure that it is storing session cookies.

Also, are both JSPs part of the same web application?
If you're not sure, tell us where each of the two JSP is on your machine.
Also post the two URLs you're using to access these JSPs.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
both jsp pages are part of same web app.
in a.jsp
session.setAttribute("name",ss1);
out.print(session.getId()); //line 1
response.sendRedirect("b.jsp");

when i typed url of a.jsp
it direct go to b.jsp not show line1
so i am not able to check whether both jsp page have same session id or not
as you said earlier that check session.getId() in both pages

 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try System.out.println() for debugging purpose. It will log the message to container log file.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it gives no effect
direct go to b.jsp
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the system Log.
I suggested to log the session Id to system log so that you can compare whether both the session ids.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's checked
now tell me why value from session not get in b.jsp
while ids are same
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please reply friends
in my browser session is stored successfully
and also there is no problem in configuring tomcat server

and session value is getting on another application
but in this appl. it is not
i am not understanding where is the problem
 
Sudhakar Sharma
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand. can we access the object multi-times which is bound once in a session
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you resolved this?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the URLs to each of the JSPs.

 
sunny nagar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.print(session.getId());// it will not print session value.
out.print((String)session.getId());//use this one to print session id.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!