• Post Reply Bookmark Topic Watch Topic
  • New Topic

jstl equivalent for the scriptlet code  RSS feed

 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii guys,

i am using tomcat 6.0.18 and jstl1.2.jar FYI
i am trying to learn jstl.
i have this code in scriptlet want to convert into jstl a little help please

thank you
 
Wesley Baker
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, that really belongs in a class or servlet, rather than a JSP, even if it's JSTL.

I would recommend making a custom tag library (TLD) which uses the class, and calling it with JSTL on the JSP. You can Google for a few different ways to accomplish this.
 
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
Indeed. The JSTL and EL where not set up to be merely a drop-in replacement for whatever Java code has been placed within JSPs. They were set up to make sure that processing did not make its way into JSPs. As such, there's lots of support for showing things, but not for doing things.

For example, setting the session max interval is not a suitable action to be taking in a JSP.
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys for your replies but actually this code is in my logout.jsp page and i am calling it on a click of a link to remove all the attributes and redirecting the user to the homepage. if this is not the correct way then shall i put this code in a servlet and remove all the attributes?? rite
 
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 answer that question yourself by asking the simple question:

"Does the link do something, or show something?"

If the answer is "do", not a JSP.

If the answer is "show", JSP.

Be aware that if anything needs to be "done" before "showing" something (such as fetching info from the DB), then that's the same as "do" where a servlet page controller takes care of the "do" then forwards to a JSP that handles the "show".
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you bear and wesley,
For the valuable inputs. i will do it in the servlet. but just for the knowledge part of it. how would i write the same using the jstl tags. so that i can get all the attributes from the session.
Thank you once again.
 
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
That part's easy. The hint is that the built-in variable sessionScope is a Map implementation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!