Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
abhijeet srivastava
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

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

bye......
 
pradheesh manohar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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;
//
}
 
prashant kond
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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 />
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • 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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!