• 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

converting javascript string value to jsp string value and vice-versa

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all!

please tell how we can convert javascript string value to jsp string value and vice-versa

bye......
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi abhijeet,
you would mostly require jsp variable to be passed in as string argument for JS functions like this




onClick(any event for that mattter)="javascriptFunction("<"%=jspVarName%>)"



function javascriptFunction(jspVar){
var temp=jspVar;
//
}
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can send jsp string to js as parameter.
ex: onClick()="javascript:temp('testString');

if you want to access js String in jsp you have to define by using struts of jstl.
<bean:define name="test" value="any" id="test"/>
or by <c:set />
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sigh.

Java is NOT javascript. The two do not communicate directly.

To get a value from javascript to java, you need to send it as a request parameter with a request. (Click a link, submit a form...)

There was an article in one of the javaranch journals that answered this question (though probably not how you want it answered)
http://www.javaranch.com/journal/200510/Journal200510.jsp#a1
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic