wont parse EL in quotes
I am trying to transfer data from a POJO into a javascript object, for a printing ActiveX control.
The problem is that the EL will not parse inside of a String literal. I have tried " and '
I tried a <c:out> but this has the same problem
I am using JSP 1.2 on websphere 6.0. We are using JSTL 1.1
I have found that I must include this line in my JSP to get JSTL to parse at all.I dont know what is up with that
<%@ page isELIgnored="false"%>
I can get this to work no problem with scriptlets, but I would like to make this work with JSTL only!
<% Customer c = (Customer) request.getAttribute("customer");%>
function setLicenseTemplate(){
// JSTL wont parse
decalFormat.SetNamedSubStringValue("custId","${customer.id}");
// scriptlets work
decalFormat.SetNamedSubStringValue("name","<%=customer.getName()%>");
>I am using JSP 1.2 on websphere 6.0. We are using JSTL 1.1
JSTL1.1 is meant to go with JSP2.0
The <%@ page isELIgnored="false"%> is a JSP2.0 tag. It had no meaning in JSP1.2, and would generate an error.
Websphere 6.0 is J2EE1.4 compliant, and hence is a JSP2.0 container.
Basically if you want to program to the JSP1.2 standards, you have to use JSTL version 1.0.
Couple of other forum posts that might help explain matters
http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0
http://forum.java.sun.com/thread.jspa?threadID=628740
Good luck,
evnafets
We are using J2EE 1.4, so we should be on JSP2.0 I think is what i am hearing. The project properties claim that we are at Web Level 2.3 (whatever that means) and it says this "Web 2.3 includes Servlet specification 2.3 and JSP specification 1.2"
I am trying to figure out if i need to do anything to migrate up to JSP 2.0. I am hoping not. It seems like we must already be at 2.0, if EL works outside of a c:out (which it does). But this would be a Websphere question, which is out of scope on this forum (though any comments on this are appeciated)
If this is the case, then my problem is not a JSTL1.0 vs JSTL1.1 issue. So, are there any other ideas on how I can get EL to parse inside of quotes for javascript?
> We are using J2EE 1.4, so we should be on JSP2.0 I
> think is what i am hearing. The project properties
> claim that we are at Web Level 2.3 (whatever that
> means) and it says this "Web 2.3 includes Servlet
> specification 2.3 and JSP specification 1.2"
>
> I am trying to figure out if i need to do anything to
> migrate up to JSP 2.0. I am hoping not. It seems
> like we must already be at 2.0, if EL works outside
> of a c:out (which it does). But this would be a
> Websphere question, which is out of scope on this
> forum (though any comments on this are appeciated)
So what version of the Servlet Spec is used (and as a result, the JSP version) is defined in your web.xml. Look up the responses in those links evnafets posted to see how to control that (specifically look at evnafets' responses in said threads).
Once you define your web.xml specs correctly, you will be using JSP 2.0
>
> If this is the case, then my problem is not a JSTL1.0
> vs JSTL1.1 issue. So, are there any other ideas on
> how I can get EL to parse inside of quotes for
> javascript?
Only when you have the JSP 2.0 spec being applied (see above) will you be able to leverage JSTL 1.1 and EL the way you want.
You also need to be keenly aware of scoping issues in EL vs. scriptlets. The customer defined in:
<% Customer customer = (Customer) request.getAttribute("customer");%>
or
<% Customer customer = new Customer() %>
may not be available to EL (EL doesn't look in the local method scope like scriptlets do).
So if all else fails, try ${request.customer.id} (which is like calling request.getAttribute("customer").getId()) to force EL to look in the request scope for the object you want to work.
Web level 2.3 probably refers to the version of the servlet specification - Servlet2.3/JSP1.2
The J2EE 1.4 incorporates Servlet2.4/JSP2.0
Was there a reason you are coding to JSP1.2 - ie client target machine only supported JSP1.2?
>So, are there any other ideas on how I can get EL to parse inside of
>quotes for javascript?
Just as a question, does it work when you include the isELIgnored directive on the page?
As mentioned in those other posts I referred to, if you update your web.xml file to be version 2.4, then EL should work on all pages withouth the need for the isELIgnored directive.
On the server, javascript should be irrelevant.
It should not matter in the slightest that your ${expr} is embedded in quotes, because the quotes are just template text - ie strings to be just passed right through into the result.
For instance if you have
Customer id : ${customer.id}
Customer id : "${customer.id}"
and the customer id is 42, then you should see:
Customer id : 42
Customer id : "42"
If this is not the case, I would say there is an issue with the parser.
Hope this helps some,
evnafets
Thanks for all the input guys.
There is no reason for us to stay with JSP1.2, other than that everything has worked up until now, and therefore i didnt see any reason to try to break it.
I will try the web.xml changes, and see what that does. I pretty much figured that I would have to get all this 1.1/ 1.2/ 2.3/ 2.0 stuff figured out at some point, and you guys have helped a ton.