• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data set inside the session is lost when response.sendRedirect has been used  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am having a JSP Page in which i am setting all the values in a Session as shown below :


But to my surprise inside Blowup.jsp when i tried to extract username and password from the hss . They return me null .

Can anybody please tell me what might be the problem.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please post the full code .
avi sinha
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jsp page contains 5000 lines of code (Developed in 2006) Nobody interested to change it now
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran V wrote:The jsp page contains 5000 lines of code (Developed in 2006) Nobody interested to change it now


well then please post the code from the "if{...}" related to this else if

avi sinha
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is something wrong with the code.
because :
1> an "else if" can't exist without an "if".
2> there can be no any code in between "if" and "else if".

hence either the codes for setting the attribute is inside an if statement or the code will not compile.
since you are getting null hence they are inside "if" now you can understand why you are getting null.

avi sinha
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is this line is working for you? Is it redirecting you to Blowup.jsp?
 
Paul Clapham
Sheriff
Posts: 22507
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Singh wrote:

Is this line is working for you? Is it redirecting you to Blowup.jsp?


If the answer is "yes", then notice that it is in an "else" clause. That would imply that lines 3 and 4 were never executed, being in the other half of the if-else structure.

You could also determine that by putting in some debugging code. That might be easier than posting code fragments here.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the answer is "yes", then notice that it is in an "else" clause. That would imply that lines 3 and 4 were never executed, being in the other half of the if-else structure.



What do you mean by this ??
 
Paul Clapham
Sheriff
Posts: 22507
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just basic Java programming. You posted a fragment of this code:

So... you understand how if-else works, right? Which code is executed when "something" is true? Which code is executed when "something" is false?

Now that you have answered those two questions, which lines of code were (and were not) executed if the "response.sendRedirect" was executed?

It's just basic Java programming, right? Although it does help if you aren't looking at only a fragment of the code. And it's easier to see if the code is consistently formatted instead of being randomly indented. Perhaps you might want to clean up the code you were left with so it's easier to read.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh

May be you are right . I need to check the code once again .

Thanks once again for your time .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!