• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scriptlet to JSTL  RSS feed

 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have the following in Tomcat 6.1.20 working in my JSP and now want to eliminate the Scriptlet and use JSTL:


My attempt didnt work because it doesnt like my JSTL part:


Please advise how I can get this to work using JSTL instead of Scriptlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with the JSTL -- this is an EL question.

And the answer is that the EL can't call general methods by design -- it is intended to work only with bean properties. Method calls with parameters are not valid bean properties and hence cannot be invoked.

Beans should be designed as beans, and not be general classes masquerading as beans.

If you really need to call a general method, you can explore defining custom tags or EL functions.
 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:This has nothing to do with the JSTL -- this is an EL question.

And the answer is that the EL can't call general methods by design -- it is intended to work only with bean properties. Method calls with parameters are not valid bean properties and hence cannot be invoked.

Beans should be designed as beans, and not be general classes masquerading as beans.

If you really need to call a general method, you can explore defining custom tags or EL functions.


Thanks, I will google and read on how to define custom tag or EL function and decide which is best for my situation.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, rather than simply do a line-by-line scriptlet-->EL/JSTL conversion, sit back and decide how to refactor the page not to need to do such things in the first place.
 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dont fall in trap.

use scriptlet if you are comfirtable with it. i never saw a pure graphic designer maintaining a jsp. even if he is doing, el or jstl is not going to be understood by him anyway.

 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pooja jain wrote:dont fall in trap.

use scriptlet if you are comfirtable with it. i never saw a pure graphic designer maintaining a jsp. even if he is doing, el or jstl is not going to be understood by him anyway.



its not a trap. it doesn't matter whether you have seen a graphic designer maintaining a jsp or not. may be one day a jsp/el programmer will have to maintain it.

and keep in mind scripting inside a jsp page is deprecated so we should not use scripting inside a jsp.

it will be a lame excuse that you are not comfortable with these.just try to figure it out. if you can learn java you can learn it easily.

avi sinha
 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avi sinha wrote:

and keep in mind scripting inside a jsp page is deprecated so we should not use scripting inside a jsp.



any supporting url???
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry pooja i didn't understand ...
what does it mean "supporting url".
 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avi sinha wrote:sorry pooja i didn't understand ...
what does it mean "supporting url".


any url which says that scriptlet is depricated.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read This

avi sinha
 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avi sinha wrote:Read This

avi sinha


parden me but i didn't find any such URL in that thread either.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pooja jain wrote:
avi sinha wrote:Read This

avi sinha


parden me but i didn't find any such URL in that thread either.


well my mistake :

scriptlet is not deprecated, only its use is not recommended.

avi sinha
 
pooja jain
greenhorn
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its ok avi.

that's not the point anyway.

the point is, it sounds good on ear that jsp shouldn't have the scriptlets but i am in an opinion that use jsp for presentation but things like iterating list, getting things form request, session, iterating any custom object etc can be done in scriptlet if you are comfirtable with it.

i dont buy this argument that scriptlet makes hard to read jsp.

have fun.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pooja jain wrote:its ok avi.

that's not the point anyway.

the point is, it sounds good on ear that jsp shouldn't have the scriptlets but i am in an opinion that use jsp for presentation but things like iterating list, getting things form request, session, iterating any custom object etc can be done in scriptlet if you are comfortable with it.

have fun.


ya of course it can be done using scripting but using actions and el is even better and easier in my opinion.

avi sinha
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write JSPs like it's 2001 with scriptlets, or you can move to modern accepted best practices and move up to JSTL/EL. No one can make you write good code. The choice is yours.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!