Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scope of Jsp Variables, Urgent

 
Kishan Kumar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am coding a JSP page in which iam declaring some variables and initialising to some initial values. In the course of the page these variables value are changed depending on business logic, everything is ok for the first time, but when i call the jsp for the second time it is not initialising to the initial values which i have set at the time of decleration, instead
it is keeping the values of the previous call. When i change those variables in bussiness logic it is changing but when my bussiness logic does not touch these variables i want my variables to have the initial values which i have set during the decleration, this is not happenning. Why on each call of the jsp, the decleration part is not executing, if it does not execute how do i accomplish my objective.
Thanks in Advance,

------------------
Regards,
V. Kishan Kumar
 
Kishan Kumar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please somebody come forward to reply to my query.
Thanks In Advance
------------------
Regards,
V. Kishan Kumar
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your variable declarations are inside a <% %> section in your JSP, they will be initilaized on each request. If you wish them to remain between requests you should either put the values in the session, put the values in the servlet context, or declare them in a <%! %> section.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic