Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

check this out!!

 
asheet anand
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,
i simply want to use an javascript array ina jsp code.
my requirement is i want to use the values of an arrar of javascript in jsp.
i tried
<%t1.add(%><script language="javascript">document.write(a1)</script><%)%>
where a1 is the java script array
and t1 is the java object which uses a1 to call a method "add".
thanks
asheet
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anand,
We can't break the scriplets like this. The java code inside scriplets should atleast be an eligible java statement. We can't break a function's argument alone.
Also try to minimize the java code in jsp. jsp is meant to be used for presentation. It will be a huge head-ache if we mix and scatter lots java code within html/javascript code!
Even if you are responsible for the whole appn development, when we re-visit the code after few months, we may not get the logic easily. It could be a huge maintainence nightmare.
Javascript is going to run in client's browser and jsp scriplet will run at server. If we break the scriplet like above, how the code can run at server? Because the javascript will not be able to run and give argument values to your t1.add(...) method. Isn't ?
regds
maha anna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic