I start learning jsp application, and sometimes i got the error message “something cannot be resolved…”. For example, this is my last report:
An error occurred at line: 118 in the jsp file: /functions.jsp
session cannot be resolved
115:
116: Boolean isLogged()
117: {
118: Boolean loginSuccess = (Boolean)session.getAttribute("myApp.loginSuccess");
119: if (loginSuccess == null)
120: {
121: return false;
These lines refer to a function, that checks the success of the login procedure. So i have two questions:
- How can i fix the problem in this situation?
- What’s the reason of these messages, that sometimes disappears with no cause?
You need to cast the returned value of
getAttribute()method.You can’t use
implicitobject variables directly into method body (declaration). You should have to avoid Java code in JSPs (Declaration, Scriptlet and Expression). Alternatively you can use use Servlet/Filter.To fix this issue declare a reference variable of
HttpSessionin declaration block.and assign the reference of
sessionobject tosessvariable before you call theisLoggedmethod.e.g