You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andreja <ka...@gmail.com> on 2007/07/05 13:45:53 UTC
S2 and JFreeChart (showing images)
I have an action where I create graph(s), and I need to display them
in the page. It is ArrayList<JFreeChart> that I need to show, but for
the start I will try to display only one graph.
Action code goes like this:
public class ChartDisplayAction () {
...
execute() {
HttpSession session = servletRequest.getSession();
JFreeChart mygraph = ...creating graph...
BufferedImage myBuffered = mygraph.createBufferedImage(600, 400);
session.setAttribute("myBuffered", myBuffered);
}
...
}
.jsp page code:
<img src="<%=session.getAttribute("myBuffered")%>" border=0 usemap="#imageMap">
Obviously, I am making the mistake here (most probably when I am
trying to put myBuffered in session scope), but chart that I want to
display is not in file, it is in a stream, and there must be a way to
pass the stream to .jsp page. How do I do that?
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: S2 and JFreeChart (showing images)
Posted by Peng Tuck Kwok <pe...@gmail.com>.
hmm page not updated in a while. Maybe not worth if that's the case.
On 7/6/07, Peng Tuck Kwok <pe...@gmail.com> wrote:
>
> You could possibly use Cewolf, which provides a set of tag libraries that
> you can you to display a chart in your jsp page. Link is here<http://cewolf.sourceforge.net/new/index.html>.
> I've played with it a while back and it did seem easy to get a simple chart
> up. Worth a look if you ask me.
>
> On 7/5/07, Andreja <ka...@gmail.com> wrote:
> >
> > I have an action where I create graph(s), and I need to display them
> > in the page. It is ArrayList<JFreeChart> that I need to show, but for
> > the start I will try to display only one graph.
> >
> >
> > Action code goes like this:
> >
> > public class ChartDisplayAction () {
> > ...
> > execute() {
> > HttpSession session = servletRequest.getSession();
> > JFreeChart mygraph = ...creating graph...
> > BufferedImage myBuffered = mygraph.createBufferedImage (600, 400);
> > session.setAttribute("myBuffered", myBuffered);
> > }
> > ...
> > }
> >
> >
> > .jsp page code:
> >
> > <img src="<%=session.getAttribute("myBuffered")%>" border=0
> > usemap="#imageMap">
> >
> > Obviously, I am making the mistake here (most probably when I am
> > trying to put myBuffered in session scope), but chart that I want to
> > display is not in file, it is in a stream, and there must be a way to
> > pass the stream to .jsp page. How do I do that?
> >
> > Thanks!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Re: S2 and JFreeChart (showing images)
Posted by Peng Tuck Kwok <pe...@gmail.com>.
You could possibly use Cewolf, which provides a set of tag libraries that
you can you to display a chart in your jsp page. Link is
here<http://cewolf.sourceforge.net/new/index.html>.
I've played with it a while back and it did seem easy to get a simple chart
up. Worth a look if you ask me.
On 7/5/07, Andreja <ka...@gmail.com> wrote:
>
> I have an action where I create graph(s), and I need to display them
> in the page. It is ArrayList<JFreeChart> that I need to show, but for
> the start I will try to display only one graph.
>
>
> Action code goes like this:
>
> public class ChartDisplayAction () {
> ...
> execute() {
> HttpSession session = servletRequest.getSession();
> JFreeChart mygraph = ...creating graph...
> BufferedImage myBuffered = mygraph.createBufferedImage(600, 400);
> session.setAttribute("myBuffered", myBuffered);
> }
> ...
> }
>
>
> .jsp page code:
>
> <img src="<%=session.getAttribute("myBuffered")%>" border=0
> usemap="#imageMap">
>
> Obviously, I am making the mistake here (most probably when I am
> trying to put myBuffered in session scope), but chart that I want to
> display is not in file, it is in a stream, and there must be a way to
> pass the stream to .jsp page. How do I do that?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: S2 and JFreeChart (showing images)
Posted by Andreja <ka...@gmail.com>.
First, thank you for the answer!
>Are you accessing the session in the S2 way
>by implementing sessionaware and
>having a setSession method?
No, I didn't do that, because I don't understand how to implement
setSession method.
public void setSession(Map arg0) {
???
}
How does Map realte to HttpSession field, I don't know.
On jsp page I have several (30-40) pictures that I would like to show
dynamically (pictures are in memory, not in files on disk), and I use
jsp code that looks like this:
<s:iterator value="generatedCharts" status="cnt">
<s:url id="url" action="GraphsServer" method="showGraph">
<s:param name="id">${cnt.index}</s:param>
</s:url>
<img src="${url}">
</s:iterator>
(it renders HTML like this: <img src="/GraphsServer!showGraph.action?id=0"> )
In action, there is a field: ArrayField<JFreeChart> generatedCharts,
and showGraph method takes the "id" filed to send output stream:
os = servletResponse.getOutputStream();
ChartUtilities.writeChartAsPNG(os,
generatedCharts.get(Integer.valueOf(id)), 600, 400);
os.flush();
Each time .getOutputStream() is called, the following exception happens:
java.lang.IllegalStateException: getOutputStream() has already been
called for this response
Is there a way to do this?
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: RedirectingActionForward and the request object?
Posted by Paul Benedict <pb...@apache.org>.
Cary, you are confusing attributes and parameters. Attributes are internal
data points about the request, while parameters are external data points. If
you want to retain data you have two choices:
1) Add parameters to the redirect
2) Store data in the session
Paul
On 7/9/07, Cary Ho <ch...@weddingwire.com> wrote:
>
> Is there a way to redirect, send them to a different page, but keep
> information in the request so the jsp its forwarded to can use
> information passed in the request attributes?
>
> Paul Benedict wrote:
> > Cary,
> >
> > A redirect causes a second request. You're putting data in the first
> > request, redirecting, which then loses the data as the browser sends a
> > new request.
> >
> > Paul
> >
>
Re: RedirectingActionForward and the request object?
Posted by Cary Ho <ch...@weddingwire.com>.
Is there a way to redirect, send them to a different page, but keep
information in the request so the jsp its forwarded to can use
information passed in the request attributes?
Paul Benedict wrote:
> Cary,
>
> A redirect causes a second request. You're putting data in the first
> request, redirecting, which then loses the data as the browser sends a
> new request.
>
> Paul
>
> Cary Ho wrote:
>> Im using a RedirectingActionForward in a struts actions (Struts
>> 1.3.x) to take a person to another page under certain circumstances.
>> When I do this, anything I put in the request objects setAttribute
>> doesnt seem to carry to the new page. Is there a way to move the
>> stuff I put in the request object to carry along in the forward?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: RedirectingActionForward and the request object?
Posted by Paul Benedict <pb...@apache.org>.
Cary,
A redirect causes a second request. You're putting data in the first
request, redirecting, which then loses the data as the browser sends a
new request.
Paul
Cary Ho wrote:
> Im using a RedirectingActionForward in a struts actions (Struts 1.3.x)
> to take a person to another page under certain circumstances. When I
> do this, anything I put in the request objects setAttribute doesnt
> seem to carry to the new page. Is there a way to move the stuff I put
> in the request object to carry along in the forward?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RedirectingActionForward and the request object?
Posted by Cary Ho <ch...@weddingwire.com>.
Im using a RedirectingActionForward in a struts actions (Struts 1.3.x)
to take a person to another page under certain circumstances. When I do
this, anything I put in the request objects setAttribute doesnt seem to
carry to the new page. Is there a way to move the stuff I put in the
request object to carry along in the forward?
Re: S2 and JFreeChart (showing images)
Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Are you accessing the session in the S2 way by implementing sessionaware and
having a setSession method?
I don't have any JFreeChart experience but apart from the session access
code I can't see why it wouldn't work.
Z.
> I have an action where I create graph(s), and I need to display them
> in the page. It is ArrayList<JFreeChart> that I need to show, but for
> the start I will try to display only one graph.
>
>
> Action code goes like this:
>
> public class ChartDisplayAction () {
> ...
> execute() {
> HttpSession session = servletRequest.getSession();
> JFreeChart mygraph = ...creating graph...
> BufferedImage myBuffered = mygraph.createBufferedImage(600, 400);
> session.setAttribute("myBuffered", myBuffered);
> }
> ...
> }
>
>
> .jsp page code:
>
> <img src="<%=session.getAttribute("myBuffered")%>" border=0
> usemap="#imageMap">
>
> Obviously, I am making the mistake here (most probably when I am
> trying to put myBuffered in session scope), but chart that I want to
> display is not in file, it is in a stream, and there must be a way to
> pass the stream to .jsp page. How do I do that?
>
> Thanks!
>
> ---------------------------------------------------------------------
> 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