• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help in JSTL And EL

 
Khaled abdo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
i am new at EL and JSTL

can anyone help me how to Access this attribute
This is JSP
if(request.getAttribute("UPDATE_PASSWORD") != null && request.getAttribute("UPDATE_PASSWORD").equals(true)) {


this is the JAVA static bean
and the code is public static final String UPDATE_PASSWORD ="UPDATE_PASSWORD";
and this is the setAttribute :
request.setAttribute("UPDATE_PASSWORD",true);

please am new in programming help me Please
[ December 18, 2008: Message edited by: Bear Bibeault ]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Khaled abdo:
Hello
i am new at EL and JSTL

can anyone help me how to Access this attribute
This is JSP
if(request.getAttribute("UPDATE_PASSWORD") != null && request.getAttribute("UPDATE_PASSWORD").equals(true)) {


this is the JAVA static bean
and the code is public static final String UPDATE_PASSWORD ="UPDATE_PASSWORD";
and this is the setAttribute :
request.setAttribute("UPDATE_PASSWORD",true);

please am new in programming help me Please


So to access the request attribute "UPDATE_PASSWORD" from EL you could do:


Note that in this case the .UPDATE_PASSWORD refers to the value "UPDATE_PASSWORD" not the static constant String variable. So for example, if your constant was defined as:

the EL would still be:
and not

You ask about using a static constant as the name of the parameter in EL. This is typically not done, the Key names for values are typically directly used. Though using static constants is possible using Maps and/or Reflection the workarounds get to be a bit of a mess and seem a bit hard to manage when all you really are looking to do is prevent mis-typing.
 
Khaled abdo
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Alot.
Do i have to write something in the .tld?
or shall i create one?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There were a number of errors in Steve's post.

Firstly, the syntax to directly address request scope would be:
And secondly, you cannot directly address class constants with the EL. To do so, please see this article.

I also recommend using conventional naming for your scoped variables. Rather than UPDATE_PASSWORD< us updatePassword.
[ December 18, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Khaled abdo:
Do i have to write something in the .tld?
or shall i create one?

No. You don't need to do anything with TLDs.

To enable the EL, be sure that your web app is properly declared as outline in the JSP FAQs.

To use the JSTL, simply drop the jar files in WEB-INF/lib. This is also covered in the JSP FAQs. Be sure to use the correct version of the JSTL for the version of JSP that you are using.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!