This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

el-ignored query

 
Dhruvi Manchanda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you access the page ? Can you post the url ?
 
Dhruvi Manchanda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Dhruvi Manchanda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Even I faced the same problem. Which one are you using as app server and what is it's version?
 
Dhruvi Manchanda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Tomcat web container version 5.0
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou for help. But it is not working in Tomcat5.0
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check Tomcat's logs ? Don't you get any errors ?
 
Dhruvi Manchanda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check Tomcat's logs ? Don't you get any errors ?


I checked the logs,there are no errors.
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 again
  • open 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 again
  • open 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
    Posts: 15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 83
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Ha Minh Nam
    Greenhorn
    Posts: 14
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Christophe Verré
    Sheriff
    Posts: 14691
    16
    Eclipse IDE Ubuntu VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 83
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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!
     
    mak pandian
    Ranch Hand
    Posts: 30
    Eclipse IDE Java Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Johan Pelgrim,

    I also have had this issue and have been looking fix for 2 days.

    Your bruteforce logic works out well..
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic