• Post Reply Bookmark Topic Watch Topic
  • New Topic

passing EL variable to scriptlet  RSS feed

 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having an EL variable

now I want to pass it to a scriptlet which invokes a method,
something like


where print is printing the variable.

regards.
RJ
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a flaw in your design. You shouldn't be using scriptlets.

What's the functional requirement after all?
 
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
Why would you be mixing the EL and scriptlets? The JSTL and EL are meant to replace scriptlets, not to work in conjunction with them. Either use scriptlets, or use the EL. Mixing them is just a mess.
 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes its true,
but JSTL and EL are so easy to populate data from database and create page design,
where as scriptlets are doing some logic work for me,using the current iterator value of EL....

Though I had converted it fully to scriptlet as time was short for me. But I would surely like to know as we can integrate scriptlate values in JSTL but weather the reverse is possible or not??


Regards
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JSP is for view. All the logic goes in the servlet,always. JSP is developed to generate view as putting html inside a servlet was bad. In any book you won't see any logic inside a JSP.
And regarding your question,as far as i think it can't be done.
 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought so as I didn't found any thing for help in said direction.
Thankn though for your time.

Regards,
Rudradutt
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can get the EL variable value in your scriptlet.

Try using pageContext.getParameter to get the value in your scriptlet
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repeat, it is a bad practice. This isn't 1998. This is 2008.
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree but I guess it would be in ideal condition. Time crunch and work load leads us to use scriptlets which can do your things faster rather then taglib.

I am working on Liferay Portal they have used both taglib and scriptlets .
 
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
Originally posted by saumil baxi:
Try using pageContext.getParameter to get the value in your scriptlet

There is no such method. I assume you meant findAttribute()?

Originally posted by saumil baxi:
i agree but I guess it would be in ideal condition. Time crunch and work load leads us to use scriptlets which can do your things faster rather then taglib.
In a properly organized web application, it's generally much faster to do it right with JSTL and EL.

Originally posted by saumil baxi:
u can get the ...

Please use real words when posting to the forums. Abbreviations such as "u" in place of "you" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Rudradutt Joshi
Ranch Hand
Posts: 45
Fedora Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are simply genius,
This will be handy sometimes, until i improve my programing methodologies.
its

<%=pageContext.getAttribute(PARAMETER NAME)%>

[ December 22, 2008: Message edited by: rudradutt joshi ]
 
Rune Hellem
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:I repeat, it is a bad practice. This isn't 1998. This is 2008.


But sometimes you might have to do it even if it is bad practice, currently facing a problem on WebSphere Portal where I don't get fmt:formatDate or my custom taglib to work. My post on IBM DW. So for the time being I have to use scriptlet in my app when deploying on WebSphere
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fine, but why are you resurrecting an old topic for that?

Workarounding a bug caused by 3rd party isn't still a valid reason to use scriptlets. You could perfectly use a servlet or javabean for this. After all I would still push IBM to get that bug fixed or so.
 
Rune Hellem
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Fine, but why are you resurrecting an old topic for that?

Personally I don't consider a topic not even two months for being "to old", and when considering your comment "..This isn't 1998. This is 2008..." you should not be all that surprised that someone would want to give a comment on that...

Bauke Scholtz wrote:Workarounding a bug caused by 3rd party isn't still a valid reason to use scriptlets. You could perfectly use a servlet or javabean for this.

I'm aware of the fact that I could have used a javabean, but when creating the workaround I considered the use of scriplet the lowest common multiplum - whatever I would have done, it would still have been a workaround so I did not want to spend to much time considering other options.

Bauke Scholtz wrote:After all I would still push IBM to get that bug fixed or so.

...If I had the time to wait so long, I would
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's just your own issue. Fact is, scriptlets indicate bad design at any way. That's all.
 
aschwin versteegden
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rune Hellem wrote:
Bauke Scholtz wrote:I repeat, it is a bad practice. This isn't 1998. This is 2008.


But sometimes you might have to do it even if it is bad practice, currently facing a problem on WebSphere Portal where I don't get fmt:formatDate or my custom taglib to work. My post on IBM DW. So for the time being I have to use scriptlet in my app when deploying on WebSphere


But how do you deal with JAR files you use without a tag lib?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!