• 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

pass Sciptlet to jsp

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii..
I want to use a scriplet variable in javascript.
i used
<%! int i;>
<% i=0; %>
<input type="text" id="itemValue" onchange=changeValue('<%=i%>')>

it works fine if i give alert(i) in
changeValue() function.
Otherwise it gives error i is undefined.
Please help me. I don't want to bother user by increasing one user click.
Please help what is the reason ???

i m using struts 1.2

 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you copy-pasted directly that code? This <%! int i;> cannot be compiling...

With so few code is difficult to help you, just with this it should work (as far as you close properly the scriptlet tag I mentieoned before.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mamata,
Welcome to javaranch.

can you post your javascript function also?
signature of that should be


then it will work.

and use code tags to post code.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mamata Chaudhari wrote:I want to use a scriplet variable in javascript.



It is poor practise . Use EL
 
Mamata Chaudhari
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply
but that textbox is in logic:iterate.
I want to identify in javascript.
I used indexed property of logic:iterate.
but not working.
How can i use EL??
I don't have any idea.

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I suppose this has become a Struts question. Anyways, I don't know much about Struts 1.2, but looking at this reference I think you can use indexId attribute to specify a name for a bean that will contain the index of the current iteration which you can use instead of the scripting (you also mentioned that you used indexed property of iterate tag, maybe you made a typo or something)...
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mamata,

Please post code you tried so we will better understand problem.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic