• Post Reply Bookmark Topic Watch Topic
  • New Topic

static content access

 
prashant kond
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am unable to access Static content from javascript. My requirement is like, I have to pass javascript variable to HashMap to get the result. But since HashMap code is in java,it is not allowing me to send javascript variable as parameter.
Please look at the code once.

for(var i=0; i < availableModules.options.length; i++){
if (availableModules.options[i].selected){
subModuleId = availableModules.options[i].value;
moduleId = '<%=OtrServiceConstants.MODULE_MAP.get("subModuleId ") %>';
}
}

It is giving compilation errors if i use javascript varialble.
If any one has come across these problem,please suggest me to resolve.

thanks.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Executes on the SERVER and JavaScript executes on the CLIENT.

If you want to use user selections on the client, you have to post the page back to the server.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a fundamental and common misunderstanding regarding what JSP is and how it works.

This article was written specifically to clarify this issue.
 
Prafulla N. Patil
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to put one textbox in form and set the value in the javascript to that textbox and submit the from
after submitting form you will get value entered in textbox

that is the only way, it is not at all possible to send value from script to java code back in jsp
 
prabakaran perumal
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another way if U are using struts put logic:iterator for access HashMap
or put single string as a comma separated values and use javascript split for creating java script array.

note: make sure that spliter value not used in HashMap
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prabakaran perumal,

"U" is not a word. Please use real words such as "you" when posting to the forums. Please read this for more info.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!