This week's book giveaway is in the Cloud/Virtualization forum. We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line! See this thread for details.
Dear Shawn, Ok, Ill use pageContext to make the variable a scoped attribute. But, when i use the c:set to set a variable, how to call it from a scriplet ? c:set var="jstl" value="Shawn" % String jsp = pageContext.getAttribute("jstl") % is giving error. How to call 'jstl' wich is a scoped attribute set in JSTL from a scriptlet ? Yours, Sankar.B
Hi Sorry for asking this. Actually first ive used the getAttribute(jstl), i.e. without double quotes. So it gave error. After that, i used the getAttribute("jstl"), but, without converting it toString() ive used. But, still im doubt whether without using JSP scriptlet can we use JSTL ? Cos, there is no designers and all here. All html coding as well as jsp coding we developers do. Cos, this is not a web site, we develop web based applications. So, we need to use JSP coding in html pages a lot. Also, I think, if we start JSTL coding, we will forget Java syntax. Cos, all the JSTL tags use different syntax for all. So, we fear whether we can utilise JSTL or stick with JSP itself or switch over to JSF when its released. Yours, Sankar.B
Hi, What yar. Then u might've provided to declare variable in JSTL and use it without making it as an scoped attribute. Cos, declaring variables are just used for some temporary operations within that page. Or, Is there any option to declare variables in JSTL and use it without making it as an Scoped Attribute ? Ex: int x,y; String myString; like this. But, without making it as a scoped attribute. Yours, Sankar.B
Originally posted by Sankar B: [QB]Hi, What yar. Then u might've provided to declare variable in JSTL and use it without making it as an scoped attribute. Cos, declaring variables are just used for some temporary operations within that page.
I think you're fundamentally misunderstanding the way that JSP works. It is not possible for a tag to read a scripting variable. JSTL could not have done anything in this regard; it's structurally impossible based on the way that JSP compiles pages into Java servlets. What is wrong with converting a variable into a scoped attribute? It takes a single line of code and incurs an extremely minor runtime cost.
Or, Is there any option to declare variables in JSTL and use it without making it as an Scoped Attribute ? Ex: int x,y; String myString; like this. But, without making it as a scoped attribute.
You can take care of both at once with a single <jsp:useBean> tag, whether you're using a bean or not; e.g., <jsp:useBean> works with Strings. You may want to go back to first principles and read the JSP and JSTL standards.