| Author |
el-ignored query
|
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Hi, I have tried the following code in jsp <HTML> <BODY> Request param name is:${param.name}<br> Request Id is:${param.empId}<br> Request food is:${param.food}<br> food1:${paramValues.food[0]}<br> food2:${paramValues.food[1]}<br> Request param name:${paramValues.name[0]}<br> <b>${10/2}<b> </BODY> </HTML> and in my web.xml I declared <el-ignored>true</el-ignored> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config> </web-app> But it still evaluates the EL. And gives the following result Request param name is:ABC Request Id is:67 Request food is:sushi food1:sushi food2:bread Request param name:ABC 5.0 but on declaring <%@page isELIgnored="true"%> in the jsp, EL expression is ignored. As per JSP Spec if JSP configuration <el-ignored> is true and page directive isELIgnored not specified then EL should be ignored. But why is this not working here..? Can someone please help. Thanks in advance.
|
Dhruvi<br /> <br />SCJP 1.4,SCWCD
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
|
How did you access the page ? Can you post the url ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
I have used the following html to invoke the jsp, this is one the example from hfsj(scriptless jsp pg.382) <HTML> <BODY> <FORM action="TestBean.jsp"> Name:<INPUT type="text" name="name"/><BR> ID#: <INPUT type="text" name="empId"/><BR> First food:<INPUT type="text" name="food"/> <BR> second food:<input type="text" name="food"/><BR> <INPUT type="submit"/> </FORM> </BODY> </HTML>
|
 |
Johan Pelgrim
Ranch Hand
Joined: Jul 07, 2003
Posts: 105
|
|
Hi Dhruvi, This is an interesting case. It all has to do with the translated (and later compiled) JSP-page. In the first case, where you have el-ignored true in your web.xml file, the JSP-page is translated to write out.write messages like this out.write("<HTML>\r\n"); out.write("<BODY>\r\n"); out.write("\r\n"); out.write("Request param name is:"); out.write("${param.name}"); out.write("<br>\r\n"); out.write("\r\n"); out.write("Request Id is:"); out.write("${param.empId}"); out.write("<br>\r\n"); out.write("\r\n"); ... etc. I.e the hard coded Strings. When you (only) change the el-ignored setting in web.xml to false and restart your server and request this JSP-page this happens: The container checks if the TestBean.jsp page has changed since the last translation-compilation time. In this case it didn't (you only changed the web.xml setting) so the container will simply load and instantiate the already translated and compiled JSP-page. So, what you need to do is simply do a dummy change to the JSP-page so that the container will re-translate and compile your JSP-page and then you'll see stuff like this in the translated page... I.e. this is what you want to see: out.write("<HTML>\r\n"); out.write("<BODY>\r\n"); out.write("\r\n"); out.write("Request param name is:"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.name}", java.lang.String.class, (PageContext)_jspx_page_context, null, false)); out.write("<br>\r\n"); out.write("\r\n"); out.write("Request Id is:"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.empId}", java.lang.String.class, (PageContext)_jspx_page_context, null, false)); out.write("<br>\r\n"); out.write("\r\n"); ... etc. An interesting case...
|
Johan Pelgrim, The Netherlands
SCJP 1.4, SCWCD 1.4, SCBCD 5.0
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Hi Johan, I have checked the above scenario and the generated servlet code for the jsp is same as the one mentioned below: out.write("<HTML>\r\n"); out.write("<BODY>\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("Request param name is:"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.name}", java.lang.String.class, (PageContext)_jspx_page_context, null, false)); out.write("<br>\r\n"); out.write("\r\n"); out.write("Request Id is:"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.empId}", java.lang.String.class, (PageContext)_jspx_page_context, null, false)); out.write("<br>\r\n"); out.write("\r\n"); .....etc still EL is evaluated despite of declaring <el-ignored>true</el-ignored> in web.xml.
|
 |
Vani Chinta
Ranch Hand
Joined: Mar 25, 2007
Posts: 38
|
|
|
Hi, Even I faced the same problem. Which one are you using as app server and what is it's version?
|
SCJP 1.4
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
|
I am using Tomcat web container version 5.0
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
Did you try what Johan told you ? what you need to do is simply do a dummy change to the JSP-page so that the container will re-translate and compile your JSP-page and then you'll see stuff like this in the translated page
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Yes I did those changes.Please see my reply above. I have given the code of generated servlet class for the jsp. But el-ignored does not work here.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
Yes I did those changes.Please see my reply above
Do you mean that you've rebooted the container, changed your JSP file, saved it, and retried ? Please also check the date/time of the generated file.
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Do you mean that you've rebooted the container, changed your JSP file, saved it, and retried ? Please also check the date/time of the generated file.
Yes I changed the jsp file, saved it, rebooted the container and also checked the date/time of the generated servlet.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
Sorry, I'm running out of suggestions. (just in case, I've tried it on Tomcat 5.5 and it worked ok)
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
|
Thanks Satou for help. But it is not working in Tomcat5.0
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
|
Did you check Tomcat's logs ? Don't you get any errors ?
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Did you check Tomcat's logs ? Don't you get any errors ?
I checked the logs,there are no errors.
|
 |
Johan Pelgrim
Ranch Hand
Joined: Jul 07, 2003
Posts: 105
|
|
Hi Dhruvi, I'm running Tomcat 5.0.28 and it's working fine with me. Are you sure you changed the TestBean.jsp file and not e.g. the form containing the form elements which POSTs to TestBean.jsp? A brute force technique is simply remove everything in your webapp folder in Tomcat's work folder TOMCAT_HOME/work/Catalina/localhost/YourAppName for both testcases, i.e.: stop Tomcat, set the el-ignored setting to true in web.xml, remove everything from your webapp's the work folder, start Tomcat againopen the (html?) page which contains the form, fill in the fields and click submit. And check the results... Is this what should happen?stop Tomcat, set the el-ignored setting to false in web.xml, remove everything from your webapp's the work folder, start Tomcat againopen the (html?) page which contains the form, fill in the fields and click submit. And check the results... Is this what should happen? Hope this helps
|
 |
Dhruvi Manchanda
Greenhorn
Joined: Mar 20, 2007
Posts: 15
|
|
Thanks Johan for your help. It's working now. I didn't have to change the jsp. Only removing everything for tomcat's work folder(Tomcat 5.0\work\Catalina\localhost\My_App) and restarting tomcat worked for it. Earlier I had changed the jsp,restarted tomcat and also checked the generated servlet date/time. But even then it was evaluating EL. But the only change I did now was removing everything from work folder then restarting tomcat. Could you please tell me what went wrong earlier. Thanks again.
|
 |
Soniya Ahuja
Ranch Hand
Joined: Jul 20, 2008
Posts: 83
|
|
For people still pondering over such tomcat problems put this in your web.xml <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> I found this on Sun forums and it works.
|
SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
|
 |
Ha Minh Nam
Greenhorn
Joined: May 22, 2007
Posts: 14
|
|
Originally posted by Soniya Ahuja: For people still pondering over such tomcat problems put this in your web.xml <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> I found this on Sun forums and it works.
Thanks Soniya Ahuja! I also have faced this problem with Tomcat 5.5. Your great tip has really cleared my doubt.
|
SCJP 5.0 (80%)<br />SCWCD 1.5 (89%)
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
For people still pondering over such tomcat problems
This has nothing to do with the original poster's problem. As you can see, he has already configured his web.xml properly.
I found this on Sun forums and it works.
The ranch already has many useful FAQs, like this one, and this one.
|
 |
Soniya Ahuja
Ranch Hand
Joined: Jul 20, 2008
Posts: 83
|
|
Hello Christopher,
When I posted a reply with that tip from Sun forums, I was pretty new to this place, I hadn't explored much but I used to google out things.
Now I can see that there's a lot more to this forum than it appears to be. A lot of help content and excellent answers
Cheers!
|
 |
 |
|
|
subject: el-ignored query
|
|
|