java - How can I get the session values from an external.js by using Struts2 jQuery -


i need recover value session in external js. before, did in script embedded in jsp lines , worked properly:

$(window).load(function(){     var selectedserver = "<s:property value='%{#session.selectedserver}'/>";     var selectedmarket = "<s:property value='%{#session.selectedmarket}'/>"; }); 

but now, want external js , alert(selectedserver); after these lines, show me literal: <s:property value='%{#session.selectedserver}'/>, not value.

¿is syntax different in external.js?

any suggestion appreciated.

you can use javascript global variables in external script, or use function parameters pass values should obtain in jsp external function.

<script>     var selectedserver = "<s:property value='%{#session.selectedserver}'/>";     var selectedmarket = "<s:property value='%{#session.selectedmarket}'/>"; </script> 
function(selectedserver, selectedmarket){ }    

Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -