i set a static field in jsp page a.jsp:
<%!
public static int A=123;
%>
how can i get this static variable A in other JSP file? (do not include a.jsp)
it is possible?
thanks for help 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t do this. Put the variable into a larger† scope, either
request,session, orapplicationscope. Using JSTL (because scriptlets are generally bad practice):More on scoped variables.
†By “larger,” I mean “larger than
page” scope. Page scope is the default for variables created using<c:set/>, e.g. when no scope is specified.