You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Legolas Woodland <le...@gmail.com> on 2006/01/24 21:51:28 UTC

How i can make a servlet that return an image ? (image will produce by jfree)

Hi
Thank you for reading my post.
How i can make a servlet that return an image ?
Indeed i want to make a servlet and inside the servlet I want to use 
JfreeChart to produce a chart .
and in final stage i want to return that chart (image) to output.

Thank you

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


Re: How i can make a servlet that return an image ? (image will produce by jfree)

Posted by Legolas Woodland <le...@gmail.com>.
Rafael Nami wrote:
> You can use Cewolf, that is a Servlet and a Taglib that uses JFreeChart to
> produce graphics.
> http://cewolf.sourceforge.net/
>
> Best Regards
>
> Rafael Mauricio Nami
>   
I tried to use CeWolf to generate chart , but i faced some big problems.
indeed i am developing  a jsf portlet , and the reason that i post this 
question here was that in my last project which was struts base i find 
too much help here.
I tried Jenia4faces (it works like cewolf but it is jsf not jsp tags)
Unfortunetly i have a problem that i describe here :


My problem is about using a Chart library which works well in jsf
application
but it does not works in JSF portlets.
I think i find the problem but i do not know the solution.
to use this charting library we should add a servlet to web.xml

something like :


 <servlet>
   <servlet-name>Jenia internal servlet</servlet-name>
   <servlet-class>org.jenia.faces.util.Servlet</servlet-class>
   <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
   <servlet-name>Jenia internal servlet</servlet-name>
   <url-pattern>/jenia4faces/*</url-pattern>
</servlet-mapping>




so , when we try to load a chart , it will make the chart image source
something like :

http://localhost:28080/Adv/jenia4faces/chart/OAReport.jspBarChart3d_id0.png


in the above sample , adv is the name of web application which is
deployed in a servlet container.
and filter applied to make the chart render-able.


*to use the chart library in jsf portlet , i add the servlet
description as i did for web application , so i add*


 <servlet>
   <servlet-name>Jenia internal servlet</servlet-name>
   <servlet-class>org.jenia.faces.util.Servlet</servlet-class>
   <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
   <servlet-name>Jenia internal servlet</servlet-name>
   <url-pattern>/jenia4faces/*</url-pattern>
</servlet-mapping>



to my portlet web.xml file.

when we have portlet , the url to access that portlet (which indeed is a
web application) changes
for example url for a sample portlet with same web application name
will be like
http://localhost:28080/pluto/portal/Adv/

as you can see there are some prefix to web application name in the url
, but when i use chart component to show
same chart , it still look for the chart in url like :

http://localhost:28080/Adv/jenia4faces/chart/OAReport.jspBarChart3d_id0.png


As you may already sugest , the image will not render because browser is
looking in wrong place.
now i think if i find some way to map that servlet to correct url
pattern it will works.

my question is :
1-what will be new servlet url pattern ?
2-is my assumption correct ?


after i searched and asked a bit i find that i can make my charts using 
a servlet to produce image and a simple img tag.


Thank you for advice.

Re: How i can make a servlet that return an image ? (image will produce by jfree)

Posted by Rafael Nami <ra...@gmail.com>.
You can use Cewolf, that is a Servlet and a Taglib that uses JFreeChart to
produce graphics.
http://cewolf.sourceforge.net/

Best Regards

Rafael Mauricio Nami

2006/1/24, Legolas Woodland <le...@gmail.com>:
>
> Hi
> Thank you for reading my post.
> How i can make a servlet that return an image ?
> Indeed i want to make a servlet and inside the servlet I want to use
> JfreeChart to produce a chart .
> and in final stage i want to return that chart (image) to output.
>
> Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>