I want to call a static method in my jsp file using scriptlet and I want to get the value of variable in jstl like this :
<%= Utilities.splitString(${article.nommodel}); %>
It generates an error,
How can i get the value of ${article.nommodel} ?
Thanks
You are trying to use 2 different ways of coding in JSP’s together.
Syntax like
${obj.property}is Expression Language syntax and cannot be mixed with Scriptlet’s.What you can do is in your scriptlet pull the variable from whatever scope its in and use that in the scriptlet:
Untested Code:
<%String nommodel = ((foo.Article)pageContext.getAttribute("article")).getNommodel());
out.write(Utilities.splitString(nommodel));
%>
Of course, you should really try to avoid scriplets. Custom Tags are a much better way to go with JSP’s to give much better componentization and hence reuse of your code.