aspose file tools*
The moose likes JSP and the fly likes How to pass a scriptlet value into JS function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pass a scriptlet value into JS function?" Watch "How to pass a scriptlet value into JS function?" New topic
Author

How to pass a scriptlet value into JS function?

auvrm papu
Ranch Hand

Joined: Sep 01, 2005
Posts: 105
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 ]
Scott Escue
Ranch Hand

Joined: Jan 20, 2005
Posts: 34
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

Joined: Sep 01, 2005
Posts: 105
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

If you are seeing uninterpreted scriptlet code in your HTML, something is wrong in your setup not in your code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

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

Joined: Sep 01, 2005
Posts: 105
set up???
can you give me pointers? where exactly I can verify this?
auvrm papu
Ranch Hand

Joined: Sep 01, 2005
Posts: 105
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

Joined: Sep 01, 2005
Posts: 105
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass a scriptlet value into JS function?