Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with page variables in JSTL  RSS feed

 
Vasudhaiv Naresh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
we're working on JSTL, and are facing a problem.

It goes as :
The variables that are declared in the page are not accessible in the JSTL tag. But if we set them as -
pageContext.setAttribute("variable",variable);
the JSTL tag is able to access the variable.

We would like to know the nature of such variables and what's the need for adding them to the page context when they are being used in the same page where they are defined.

Another point which we have noticed is that, unlike the EL format "${variable}" if the variable is used in the expression format , viz. <%=variable%> in the JSTL tag, its working fine without having to add to the page context.

Thanks,
Naresh
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of JSTL is to avoid creating variables (or any scriptlet activity) in your JSP.
Move your control logic into servlets and your business logic, and database access into beans.
Then, forward context to the JSP and use JSTL to aid with formatting the look and feel of the page.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!