You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Timo Nentwig <ti...@nitwit.de> on 2003/03/25 18:53:25 UTC

struts: JSP expression not evaluated

Hi!

I do have a very weird problem which I don't even know struts or jasper to
address to so I post it to both mailing lists.

Below is a small piece of JSP code, the struts <html:link> tag contains an
JSP expression in the href attribute which is not evaluated, i.e. the
actuall link contains the expression just as it is printed in the source
code below as *string*. Please note that pre-building a Java String
containing the complete href link and putting that string expression into
the tag's attribute does work just well.

This does only apply to struts' <html:link> tag; <a> works just as it
should!

<%@ page language="java" %>
<%@ page contentType="text/html;charset=WINDOWS-1252"%>

<%@ taglib uri='/WEB-INF/struts-html.tld' prefix='html' %>

<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
        <head>
                <title>Test</title>
        </head>
    <body>
<%
                int var = 1;
%>

                <!-- the link won't read "blah.do?arg=1 -->
                <html:link href="blah.do?arg=<%=var%>">
                        Link
                </html:link>
        </body>
</html>

This works:


<%
    int var = 1;
    String href = "blah.do?arg=" + var;
%>
    <html:link href="<%=href%>">


Can't I see the woods for the trees or is this a bug?

Timo
--
http://nitwit.de/
http://www.jeigh.com/werk/admin/



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


Re: struts: JSP expression not evaluated

Posted by Timo Nentwig <ti...@nitwit.de>.
Jacob Hookom wrote:
> No, you will need to use single quotes for it to work properly.  You

Already tried this, same issue.


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


RE: struts: JSP expression not evaluated

Posted by Jacob Hookom <ho...@uwec.edu>.
No, you will need to use single quotes for it to work properly.  You should
also look at the <html:link> documentation for better ways of handling this
instead of using scriptlets (<%%>).

| -----Original Message-----
| From: Timo Nentwig [mailto:timo@nitwit.de]
| Sent: Tuesday, March 25, 2003 11:53 AM
| To: struts-user@jakarta.apache.org; tomcat-user@jakarta.apache.org
| Subject: struts: JSP expression not evaluated
| 
| Hi!
| 
| I do have a very weird problem which I don't even know struts or jasper to
| address to so I post it to both mailing lists.
| 
| Below is a small piece of JSP code, the struts <html:link> tag contains an
| JSP expression in the href attribute which is not evaluated, i.e. the
| actuall link contains the expression just as it is printed in the source
| code below as *string*. Please note that pre-building a Java String
| containing the complete href link and putting that string expression into
| the tag's attribute does work just well.
| 
| This does only apply to struts' <html:link> tag; <a> works just as it
| should!
| 
| <%@ page language="java" %>
| <%@ page contentType="text/html;charset=WINDOWS-1252"%>
| 
| <%@ taglib uri='/WEB-INF/struts-html.tld' prefix='html' %>
| 
| <!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
| <html>
|         <head>
|                 <title>Test</title>
|         </head>
|     <body>
| <%
|                 int var = 1;
| %>
| 
|                 <!-- the link won't read "blah.do?arg=1 -->
|                 <html:link href="blah.do?arg=<%=var%>">
|                         Link
|                 </html:link>
|         </body>
| </html>
| 
| This works:
| 
| 
| <%
|     int var = 1;
|     String href = "blah.do?arg=" + var;
| %>
|     <html:link href="<%=href%>">
| 
| 
| Can't I see the woods for the trees or is this a bug?
| 
| Timo
| --
| http://nitwit.de/
| http://www.jeigh.com/werk/admin/
| 
| 
| 
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: struts-user-help@jakarta.apache.org


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