aspose file tools*
The moose likes JSP and the fly likes pass Sciptlet to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "pass Sciptlet to jsp" Watch "pass Sciptlet to jsp" New topic
Author

pass Sciptlet to jsp

Mamata Chaudhari
Greenhorn

Joined: Apr 26, 2009
Posts: 23
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

Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
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.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
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.


Thanks,
Shailesh
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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


It is poor practise . Use EL
Mamata Chaudhari
Greenhorn

Joined: Apr 26, 2009
Posts: 23
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.

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

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)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Mamata,

Please post code you tried so we will better understand problem.
 
wood burning stoves
 
subject: pass Sciptlet to jsp