• 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

static content access

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic