• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass a scriptlet value into JS function?

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for ex:


doing this,



gave me the alerted value as



instead,

if the company.getId() --> 30
when I do like this, how to get the value 30 inside the function?

i want


Thanks!
[ April 10, 2007: Message edited by: Ais Kaly ]
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ais,

What you're describing works for me, i.e. I get the value of the java variable in my alert. Are scriptlets working at all on your page? Can your simply write out a variables value to the page body using a scriptlet? It could be possible that scriptlets are disabled for your application. Do you have anything similar to the following in your web.xml:

There may be other ways to disable scriptlets at the page or container level.
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scott,

I don't have the code mentioned in my web.xml

I tried with System outs...and the values are coming out well.
So, I'm sure scriptlets are enabled...

any help pls?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are seeing uninterpreted scriptlet code in your HTML, something is wrong in your setup not in your code.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ais Kaly:
for ex:



"ex" is not a word. Please use only real words such as "example" when posting to the forums. Please read this for more information.
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set up???
can you give me pointers? where exactly I can verify this?
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually these 2 worked:


Can anyone know why this is not working in html:text?



Moderator: can you please move this to respective forum?
 
auvrm papu
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following worked for html:text as well!

onblurr='<%="check("+company.getId()+")"%>'

Source : http://forum.java.sun.com/thread.jspa?threadID=402026&messageID=1755013
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, of course. I missed that fact that this was in a custom tag. So I take it bake... the problem is with your code.

You cannot use a scriptlet expression as part of the attribute to a custom action. It must be all of the attribute, or none.

EL expressions have no such restrictions, which is just one of the many reasons that you should no longer be using scriptlets if you are using a JSP 2.0 container.
[ April 10, 2007: Message edited by: Bear Bibeault ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<%
String url="http://localhost:8080/ui-web/images/image.png";
request.setAttribute("Url", url);

%>
<script>
function myFunc(){
var tempUrl= "<%= request.getAttribute("Url") %>" ;
}
</script>
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are going to hard-code the value into the JSP, why not just hard-code it into the JavaScript code?
 
A berm makes a great wind break. And we all like to break wind once in a while. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic