Hello there,
I’m working with a project using JSP nowadays.
That project make uses of a lot of Javascripts calls.
I don't understand why people insists put on JSP: scriptlets, CSS and Javascript at the same page.
I, really, sure… I don't uderstand.
I going to show how we can use Java's variable and use it on Javascript method… at another file.
Look below:
1 | |
- Line
8, We simplesly have set an atributesecretMessageonrequest - Line
9, Weforwardthatrequest/responseto our view nammingsecret-message.jsp
1 | |
- This method only
insertat elementsecret-messagethecontentof one variablesecretMessage
1 | |
- Line
6, we simplesly make the import of the script.js - Line
10, it’s defined the place for show de message - Line
13, at this point, we make the bind beetween Java’s variable and Javascript!
That allows us do what we need to do on right place:
Java'scode only inJSPfileJavascript'scode inJSfile- We don’t need use
var, limit the scope usinglet!
- We don’t need use


Why doing simple things appear so difficult?
xoff.