Search code examples
jspjstljspinclude

Set the value fo a variable in one jsp and retrieve in another jsp


In jsp A, I have this statement:

<c:set var="prefix" value="fe" />

In jsp A, I include jsp B and then in B, I do:
alert(${prefix});

And I get : 'fe' in undefined How can I get the value of the variable prefix in jsp B?


Solution

  • Maybe, when the jsp is rendered, alert(${perfix}) is evaluated to alert(fe). The error you are getting is a javascript error because there is probably nothing defined as fe in your code.

    What you might want to do is change it to

    <c:set var="prefix" value="'fe'" />
    

    So that it's evaluated as a String in Javascript.