You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Benedict <pa...@yahoo.com> on 2006/07/01 01:08:33 UTC

RE: Passing Struts request attribute to custom tag

Okay. So you're writing a JSP Tag file, not a JSP Java tag. Understood.

The JSP should evaluate the attribute for you. So I don't know why it is not, but I am going to take a shot in the dark.

<%@ tag isELIgnored="false" %>
Add isELIgnored="false" to the tag file directive and see what happens.

Felix Khazin <fk...@ravewireless.com> wrote: I'm using 2.0, and no I don't have rtexprvalue set to true. I am not
using a TLD. I just wrote a custom.tag put it in my WEB-INF/tags/
directory and then did this in my code: 

<%@ taglib prefix="mytags" tagdir="/WEB-INF/tags/" %>

Do I need to make a TLD, or can I just define rtexprvalue to be true in
my taglib line above?

Thank you!
Felix

-----Original Message-----
From: Paul Benedict [mailto:paul4christ79@yahoo.com] 
Sent: Friday, June 30, 2006 5:39 PM
To: Struts Users Mailing List
Subject: RE: Passing Struts request attribute to custom tag

In your TLD, do you have this set to true?
true

Also, what JSP version is your container?

Felix Khazin  wrote: Sure, Sorry about that...

My custom tag takes in an integer value and then does some math to it.
This is the error I am getting: 

java.lang.NumberFormatException: For input string: "${pageSize}"

This error is coming from a line in my custom tag where I attempt to
parse the string to get an int.

What's interesting is that my custom tag gets the string ${pageSize} and
not the evaluated string which in this is case is 9.

Felix

-----Original Message-----
From: Paul Benedict [mailto:paul4christ79@yahoo.com] 
Sent: Friday, June 30, 2006 5:26 PM
To: Struts Users Mailing List
Subject: Re: Passing Struts request attribute to custom tag

Can you explain in more detail how it doesn't work?

Felix Khazin  wrote: Hi,

 

I am having a problem with a view using struts that I can't figure
out...

 

I have a controller that sets an attribute for example:

 

request.setAttribute("pageSize", _pageSize);

 

In my view if I use JSTL like , everything
is fine and it gets output. But if I want to use that same EL expression
in a custom tag it doesn't work.

 

So for example I have  this doesn't
work. Anyone have any ideas?

 

Thank you very much,

Felix

 



    
---------------------------------
Sneak preview the  all-new Yahoo.com. It's not radically different. Just
radically better. 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



   
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



 		
---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs.Try it free. 

RE: Passing Struts request attribute to custom tag

Posted by Paul Benedict <pa...@yahoo.com>.
Felix, I wish I could have saved you the 6 hours! I went through this very same upgrade process myself, and it is not well documented that JSP-EL is off by default in a 2.3 container :-( And it gives the illusion it is on when all your EL are within JSTL tags. -- Paul

Felix Khazin <fk...@ravewireless.com> wrote: Indeed I am:

I am using http://java.sun.com/dtd/web-app_2_3.dtd

After you told me that I did the following and fixed the problem:

change



     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">


to this:


 

    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

Then after restarting tomcat I got the following error: "According to TLD or attribute directive in tag file,
attribute value does not accept any expressions".

Now my JSTL tags were broken. So after a quick Google search I found that you have to change your taglib from

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
to 
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>


After doing all this the EL is now being evaluated on the JSTL tags, and my JSP page. 6 hours wasted on this stupid problem.

Thank you very much Paul and Wendy for all your help.

Felix

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com]
Sent: Fri 6/30/2006 9:56 PM
To: Struts Users Mailing List
Subject: Re: Passing Struts request attribute to custom tag
 
On 6/30/06, Felix Khazin  wrote:

> Another interesting thing is that say i do something like:
>
> 
>
> and then in my JSP i write, for example, ${test}
. I get ${test} in the browser. So the only time that ${test} gets evaluated is when i do a 

That says your container is not evaluating the expressions.  Has this
ever worked for this app?

Check your configuration, my guess is that your web.xml is still using
the Servlet 2.3 DTD.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

RE: Passing Struts request attribute to custom tag

Posted by Felix Khazin <fk...@ravewireless.com>.
Indeed I am:

I am using http://java.sun.com/dtd/web-app_2_3.dtd

After you told me that I did the following and fixed the problem:

change

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

to this:

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<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">

Then after restarting tomcat I got the following error: "According to TLD or attribute directive in tag file,
attribute value does not accept any expressions".

Now my JSTL tags were broken. So after a quick Google search I found that you have to change your taglib from

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
to 
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>


After doing all this the EL is now being evaluated on the JSTL tags, and my JSP page. 6 hours wasted on this stupid problem.

Thank you very much Paul and Wendy for all your help.

Felix

-----Original Message-----
From: Wendy Smoak [mailto:wsmoak@gmail.com]
Sent: Fri 6/30/2006 9:56 PM
To: Struts Users Mailing List
Subject: Re: Passing Struts request attribute to custom tag
 
On 6/30/06, Felix Khazin <fk...@ravewireless.com> wrote:

> Another interesting thing is that say i do something like:
>
> <c:set var="test" value="1"/>
>
> and then in my JSP i write, for example, <p>${test}</p>. I get ${test} in the browser. So the only time that ${test} gets evaluated is when i do a <c:out value="${test}"/>

That says your container is not evaluating the expressions.  Has this
ever worked for this app?

Check your configuration, my guess is that your web.xml is still using
the Servlet 2.3 DTD.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





Re: Passing Struts request attribute to custom tag

Posted by Wendy Smoak <ws...@gmail.com>.
On 6/30/06, Felix Khazin <fk...@ravewireless.com> wrote:

> Another interesting thing is that say i do something like:
>
> <c:set var="test" value="1"/>
>
> and then in my JSP i write, for example, <p>${test}</p>. I get ${test} in the browser. So the only time that ${test} gets evaluated is when i do a <c:out value="${test}"/>

That says your container is not evaluating the expressions.  Has this
ever worked for this app?

Check your configuration, my guess is that your web.xml is still using
the Servlet 2.3 DTD.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Passing Struts request attribute to custom tag

Posted by Felix Khazin <fk...@ravewireless.com>.
Paul,

That didn't help. I've tried putting that line the tag file, and then even in my JSP page as a "page" directive. Nothing helped. Another interesting thing is that say i do something like:

<c:set var="test" value="1"/>

and then in my JSP i write, for example, <p>${test}</p>. I get ${test} in the browser. So the only time that ${test} gets evaluated is when i do a <c:out value="${test}"/>

This is so frustrating...thank you for helping me out.

Felix


-----Original Message-----
From: Paul Benedict [mailto:paul4christ79@yahoo.com]
Sent: Fri 6/30/2006 7:08 PM
To: Struts Users Mailing List
Subject: RE: Passing Struts request attribute to custom tag
 
Okay. So you're writing a JSP Tag file, not a JSP Java tag. Understood.

The JSP should evaluate the attribute for you. So I don't know why it is not, but I am going to take a shot in the dark.

<%@ tag isELIgnored="false" %>
Add isELIgnored="false" to the tag file directive and see what happens.

Felix Khazin <fk...@ravewireless.com> wrote: I'm using 2.0, and no I don't have rtexprvalue set to true. I am not
using a TLD. I just wrote a custom.tag put it in my WEB-INF/tags/
directory and then did this in my code: 

<%@ taglib prefix="mytags" tagdir="/WEB-INF/tags/" %>

Do I need to make a TLD, or can I just define rtexprvalue to be true in
my taglib line above?

Thank you!
Felix