You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by daiyna <jo...@hotmail.com> on 2008/10/08 19:32:18 UTC

Cannot call servlet from portlet using img tag

I have an imageservlet used to server dynamic images with the following
mapping in the web.xml file:

    <servlet-mapping>
            <servlet-name>ImageViewer</servlet-name>
            <url-pattern>/imageview/*</url-pattern>
    </servlet-mapping>



>From within my JSP I can call the servlet using the include tag:


         <s:include value="/imageview"/>



but when I try to access it from an img it fails.
        <s:url var="imgURL" value="/imageview"/><
        img src="${imgURL}" alt="img" width="40", height="40"/> T H I S F A
I L S


I get the following exception:



    2008-02-28 20:08:29,096 [http-8080-1 ] WARN OgnlValueStack -
     Could not find property [struts.valueStack]
    2008-02-28 20:08:29,096 [http-8080-1 ] ERROR Dispatcher -
     Could not find action or result
    There is no Action mapped for namespace / and action name imageview. -
[unknown location]
            at
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
            at
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:60)
            at
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:38)
            at
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
            at
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:466)
            at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:458)
            at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
            at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
            at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
            at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
            at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619) 



im using struts 2.1.2
-- 
View this message in context: http://www.nabble.com/Cannot-call-servlet-from-portlet-using-img-tag-tp19883653p19883653.html
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: Cannot call servlet from portlet using img tag

Posted by Laurie Harper <la...@holoweb.net>.
daiyna wrote:
> I have an imageservlet used to server dynamic images with the following
> mapping in the web.xml file:
> 
>     <servlet-mapping>
>             <servlet-name>ImageViewer</servlet-name>
>             <url-pattern>/imageview/*</url-pattern>
>     </servlet-mapping>
> 
> 
> 
> From within my JSP I can call the servlet using the include tag:
> 
> 
>          <s:include value="/imageview"/>

What does that do? It makes no sense to put image data in-line in an 
HTML page; does your servlet return image data, or is it returning a URL 
or something?

> but when I try to access it from an img it fails.
>         <s:url var="imgURL" value="/imageview"/><
>         img src="${imgURL}" alt="img" width="40", height="40"/> T H I S F A
> I L S
> 
> 
> I get the following exception:
> 
> [...]

Have you looked at the generated HTML? What's the URL in the <img> tag? 
Maybe <s:url> is prepending something to the URL that shouldn't be there 
for this use case, or appending an unwanted .action suffix or something.

L.


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


Re: Cannot call servlet from portlet using img tag

Posted by Laurie Harper <la...@holoweb.net>.
daiyna wrote:
> im sorry this is wrong:
> 
> <s:url var="imgURL" value="/imageview"/><
>         img src="${imgURL}" alt="img" width="40", height="40"/>
> 
> its like:
> <
> img src="/imageview/somepath" alt="img" width="40", height="40"/>
> 
> where somepath is the absolute path for the generated image. imageservlet
> was supposed to retrieve the local image to the page

I'm still not clear what /imageview is supposed to do/return, or what 
the URL in the generated <img> tag is meant to look like. What do you 
expect to see in your browser if you access the following URLs directly:

1. http://host:port/context/imageview
2. http://host:port/context/imageview/somepath
3. http://host:port/context/somepath

How does that differ, in each case, from what you are seeing?

L.


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


Re: Cannot call servlet from portlet using img tag

Posted by daiyna <jo...@hotmail.com>.
im sorry this is wrong:

<s:url var="imgURL" value="/imageview"/><
        img src="${imgURL}" alt="img" width="40", height="40"/>

its like:
<
img src="/imageview/somepath" alt="img" width="40", height="40"/>

where somepath is the absolute path for the generated image. imageservlet
was supposed to retrieve the local image to the page
-- 
View this message in context: http://www.nabble.com/Cannot-call-servlet-from-portlet-using-img-tag-tp19883653p19890900.html
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