You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kenton <gi...@gmail.com> on 2007/09/05 23:18:09 UTC
Simple Struts 2.0.x tag question.
"/>
I have a .jspx file in my Struts 2.0.x app.
This doesn't work: <img src="images/<s:property
value="item.imageURL"/>"/><br/>
I get this error (both editor and at runtime): The value of attribute "src"
associated with an element type "null" must not contain the '<' character.
(The above should regular non-escaped HTML, in case the formatting of this
message isn't correct)
This works, but seems like a very ugly workaround: &lt;img
src="images/<s:property value="item.imageURL"/>"/&gt;<br/>
(The above should show "&" entity notation in case the formatting of this
message isn't correct)
This: <img src="${item.imageURL}"/><br/>
Gets this error: java.io.IOException: Stream closed
This: <img src="#{item.imageURL}"/><br/>
Gets this error: PWC6317: The attributes for a standard action or an
uninterpreted tag cannot be deferred expressions
What is the best way to do this?
--
View this message in context: http://www.nabble.com/Simple-Struts-2.0.x-tag-question.-%3Cimg-src%3D%22%3Cs%3Aproperty-value%3Ditem.imageURL%22-%3E%22-%3E-tf4388166.html#a12511140
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Simple Struts 2.0.x tag question.
"/>
Posted by Laurie Harper <la...@holoweb.net>.
Kenton wrote:
> ${item.imageURL} </img>
>
> Results in this exception (Glassfish v2 RC, Struts 2.0.9, JDK 1.6.02,
> Windows XP):
>
> java.io.IOException: Stream closed
> ...
>
> Could you explain why the EL triggers this exception? Is that a bug or am I
> doing something wrong?
I'm not sure; the expression is OK, so it'll take a bit of digging to
see if there's anything more specific in the logs and/or to narrow the
problem down.
> Also, what is the ${myObj.property} and %{myObj.property} EL syntax called?
> Where can I read documentation on it?
${} is the syntax for the standard JSTL expression language. %{} is the
syntax for OGNL, the expression language that Struts provides. For more
on OGNL in Struts, see
http://struts.apache.org/2.x/docs/ognl.html
http://struts.apache.org/2.x/docs/ognl-basics.html
http://struts.apache.org/2.x/docs/tag-syntax.html
http://www.ognl.org/
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Simple Struts 2.0.x tag question.
"/>
Posted by Kenton <gi...@gmail.com>.
Thanks for the reply, Laurie! This suggestion of yours works perfectly!
(Although, I had to change var="url" to id="url")
<s:url id="url" value="%{item.imageURL}"/>
${url} </img>
Your other suggestion doesn't work. I'd like to know why this doesn't work,
as this was what I first tried (I mentioned this in my original post, btw)
${item.imageURL} </img>
Results in this exception (Glassfish v2 RC, Struts 2.0.9, JDK 1.6.02,
Windows XP):
java.io.IOException: Stream closed
at
org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:257)
at
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:161)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:219)
at
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:985)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:671)
at
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:119)
at
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
at
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
at
com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:361)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at
com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Could you explain why the EL triggers this exception? Is that a bug or am I
doing something wrong?
Also, what is the ${myObj.property} and %{myObj.property} EL syntax called?
Where can I read documentation on it?
Laurie Harper wrote:
>
> ${item.imageURL} </img>
>
> <s:url var="url" value="%{item.imageURL}"/>
> ${url} </img>
>
--
View this message in context: http://www.nabble.com/Simple-Struts-2.0.x-tag-question.-%3Cimg-src%3D%22%3Cs%3Aproperty-value%3Ditem.imageURL%22-%3E%22-%3E-tf4388166.html#a12525398
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Simple Struts 2.0.x tag question.
"/>
Posted by Laurie Harper <la...@holoweb.net>.
Kenton wrote:
> I have a .jspx file in my Struts 2.0.x app.
>
> This doesn't work: <img src="images/<s:property
> value="item.imageURL"/>"/><br/>
> I get this error (both editor and at runtime): The value of attribute "src"
> associated with an element type "null" must not contain the '<' character.
> (The above should regular non-escaped HTML, in case the formatting of this
> message isn't correct)
>
> This works, but seems like a very ugly workaround: &lt;img
> src="images/<s:property value="item.imageURL"/>"/&gt;<br/>
> (The above should show "&" entity notation in case the formatting of this
> message isn't correct)
>
> This: <img src="${item.imageURL}"/><br/>
> Gets this error: java.io.IOException: Stream closed
>
> This: <img src="#{item.imageURL}"/><br/>
> Gets this error: PWC6317: The attributes for a standard action or an
> uninterpreted tag cannot be deferred expressions
>
> What is the best way to do this?
If it's a .jspx file, it needs to be well-formed XML. You might find it
easier to use vanilla .jsp files if you're not comfortable with
authoring XML. If you need to stick with .jspx, though, one of these
might work:
<img src="${item.imageURL}"></img>
<s:url var="url" value="%{item.imageURL}"/>
<img src="${url}"></img>
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org