You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by AndyLaw <an...@roslin.ed.ac.uk> on 2011/09/02 17:21:38 UTC

Return text to jsp, plus image and imageMap from a single Data query?

I have an application that I need to develop that requires the following:

Following selection by the user of the item of interest plus up and
downstream padding, report the locations and characteristics of features of
interest found in the region and display the data graphically with clickable
links embedded in the image to allow navigation to further descriptions of
those features.

So, I have a single set of inputs, (item, up and down) and I need to
generate three things from them.

If I were just generating the text display, I would return "success" from my
action and dispatch to a jsp. In fact, that seems to be the simplest thing
to do. I can then embed in the JSP code to call another action to generate
the image and one to generate the imagemap.

But what's the best way to do that from a single database hit (rather than
fetching the same data in three separate actions)? Initial instinct says
"stick it in the session". Is that the best option?

Thanks in advance for any help/suggestions you can provide.

Later,

Andy


--
View this message in context: http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4762757.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: Return text to jsp, plus image and imageMap from a single Data query?

Posted by Brian Thompson <el...@gmail.com>.
You can embed images directly in html using base-64 encoding.

Something like
<img src="data:image/gif;base64<s:property name='encodedImage' />" /> might
do the trick.

Brian



On Mon, Sep 5, 2011 at 7:02 AM, Aaron Brown <aa...@thebrownproject.com>wrote:

> The problem is really an html problem. You cannot embed an image in a web
> page, all you can do is embed a url reference to an image. The browser, if
> it is a graphical browser and not a text reader, will find that reference
> and execute another completely separate request for the image binary. This
> is the request that should trigger your binary stream, not the first
> request
> which only gets the base html for the page.
>
> Given this model, it doesn't make much sense to fetch the image from the db
> at the same time as the metadata you need to build the textual imagemap
> definition. You would either have to just throw away the binary data or
> else
> cache it in expectation of the second request. You've said the caching
> system doesn't work for you, so you're better off just fetching the binary
> image by itself, in its own dedicated action, when that seecond request
> comes in.
>
> - Aaron
>  On Sep 5, 2011 6:10 AM, "AndyLaw" <an...@roslin.ed.ac.uk> wrote:
> >
> > On 3 Sep 2011, at 15:07, Dave Newton-6 [via Struts] wrote:
> >
> >> Okay, so I guess my question is "Why do you want to deliver the result
> in
>
> >> three separate parts?" Without a clear understanding of what you're
> trying
> >> to do and why, it's difficult to answer in a helpful way.
> >>
> >
> > The results come back in a single hit which is defined in a JSP page. The
> JSP consists of a text table representation of the database results at the
> top of the page and a graphical clickable image of those results
> underneath.
> >
> > The struts1-based version of the code which I inherited has the action
> querying the database, drawing an image to a temporary file, which is then
> referenced from within the JSP. One of the problems that they had with the
> old version (which is being replaced for a huge number of reasons, not just
> this) was the management of "temporary" files broken down frequently
> resulting in file system chaos. I would rather avoid writing stuff to file
> that can be streamed and forgotten.
> >
> > I know how to get the stream returned and I can happily generate the
> image
> as a stream and return it. I don't have a clear picture in my head though
> about how to generate that image as a stream embedded within a JSP.
> >
> > My prototype has the jsp reference the graphic-drawing action as the
> source of an image. However, if I implement that, I'll need to extract the
> data into the action that presents the jsp text and generates the image and
> its source reference. I'll also need to extract the data into the action
> that generates the referenced image and still find a way to dump back the
> html imagemap coordinates and urls to make that image clickable.
> >
> > I'm clearly suffering a brain-fade here. Is the temporary file route the
> way to go or is there something smarter and more "self managing" that I can
> do?
> >
> > Later,
> >
> > Andy
> > --------
> > Yada, yada, yada...
> >
> > The University of Edinburgh is a charitable body, registered in Scotland,
> with registration number SC005336
> > Disclaimer: This e-mail and any attachments are confidential and intended
> solely for the use of the recipient(s) to whom they are addressed. If you
> have received it in error, please destroy all copies and inform the sender.
> >
> >
> >
> >
> >
> > --
> > The University of Edinburgh is a charitable body, registered in
> > Scotland, with registration number SC005336.
> >
> >
> >
> > --
> > View this message in context:
>
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4769657.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
>

Re: Return text to jsp, plus image and imageMap from a single Data query?

Posted by Aaron Brown <aa...@thebrownproject.com>.
The problem is really an html problem. You cannot embed an image in a web
page, all you can do is embed a url reference to an image. The browser, if
it is a graphical browser and not a text reader, will find that reference
and execute another completely separate request for the image binary. This
is the request that should trigger your binary stream, not the first request
which only gets the base html for the page.

Given this model, it doesn't make much sense to fetch the image from the db
at the same time as the metadata you need to build the textual imagemap
definition. You would either have to just throw away the binary data or else
cache it in expectation of the second request. You've said the caching
system doesn't work for you, so you're better off just fetching the binary
image by itself, in its own dedicated action, when that seecond request
comes in.

- Aaron
 On Sep 5, 2011 6:10 AM, "AndyLaw" <an...@roslin.ed.ac.uk> wrote:
>
> On 3 Sep 2011, at 15:07, Dave Newton-6 [via Struts] wrote:
>
>> Okay, so I guess my question is "Why do you want to deliver the result in

>> three separate parts?" Without a clear understanding of what you're
trying
>> to do and why, it's difficult to answer in a helpful way.
>>
>
> The results come back in a single hit which is defined in a JSP page. The
JSP consists of a text table representation of the database results at the
top of the page and a graphical clickable image of those results underneath.
>
> The struts1-based version of the code which I inherited has the action
querying the database, drawing an image to a temporary file, which is then
referenced from within the JSP. One of the problems that they had with the
old version (which is being replaced for a huge number of reasons, not just
this) was the management of "temporary" files broken down frequently
resulting in file system chaos. I would rather avoid writing stuff to file
that can be streamed and forgotten.
>
> I know how to get the stream returned and I can happily generate the image
as a stream and return it. I don't have a clear picture in my head though
about how to generate that image as a stream embedded within a JSP.
>
> My prototype has the jsp reference the graphic-drawing action as the
source of an image. However, if I implement that, I'll need to extract the
data into the action that presents the jsp text and generates the image and
its source reference. I'll also need to extract the data into the action
that generates the referenced image and still find a way to dump back the
html imagemap coordinates and urls to make that image clickable.
>
> I'm clearly suffering a brain-fade here. Is the temporary file route the
way to go or is there something smarter and more "self managing" that I can
do?
>
> Later,
>
> Andy
> --------
> Yada, yada, yada...
>
> The University of Edinburgh is a charitable body, registered in Scotland,
with registration number SC005336
> Disclaimer: This e-mail and any attachments are confidential and intended
solely for the use of the recipient(s) to whom they are addressed. If you
have received it in error, please destroy all copies and inform the sender.
>
>
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>
> --
> View this message in context:
http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4769657.html
> Sent from the Struts - User mailing list archive at Nabble.com.

Re: Return text to jsp, plus image and imageMap from a single Data query?

Posted by AndyLaw <an...@roslin.ed.ac.uk>.
On 3 Sep 2011, at 15:07, Dave Newton-6 [via Struts] wrote:

> Okay, so I guess my question is "Why do you want to deliver the result in 
> three separate parts?" Without a clear understanding of what you're trying 
> to do and why, it's difficult to answer in a helpful way. 
> 

The results come back in a single hit which is defined in a JSP page. The JSP consists of a text table representation of the database results at the top of the page and a graphical clickable image of those results underneath.

The struts1-based version of the code which I inherited has the action querying the database, drawing an image to a temporary file, which is then referenced from within the JSP. One of the problems that they had with the old version (which is being replaced for a huge number of reasons, not just this) was the management of "temporary" files broken down frequently resulting in file system chaos. I would rather avoid writing stuff to file that can be streamed and forgotten.

I know how to get the stream returned and I can happily generate the image as a stream and return it. I don't have a clear picture in my head though about how to generate that image as a stream embedded within a JSP.

My prototype has the jsp reference the graphic-drawing action as the source of an image. However, if I implement that, I'll need to extract the data into the action that presents the jsp text and generates the image and its source reference. I'll also need to extract the data into the action that generates the referenced image and still find a way to dump back the html imagemap coordinates and urls to make that image clickable.

I'm clearly suffering a brain-fade here. Is the temporary file route the way to go or is there something smarter and more "self managing" that I can do?

Later,

Andy
--------
Yada, yada, yada...

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336 
Disclaimer: This e-mail and any attachments are confidential and intended solely for the use of the recipient(s) to whom they are addressed. If you have received it in error, please destroy all copies and inform the sender.





-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



--
View this message in context: http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4769657.html
Sent from the Struts - User mailing list archive at Nabble.com.

Re: Return text to jsp, plus image and imageMap from a single Data query?

Posted by Dave Newton <da...@gmail.com>.
Okay, so I guess my question is "Why do you want to deliver the result in
three separate parts?" Without a clear understanding of what you're trying
to do and why, it's difficult to answer in a helpful way.

In any case, you can return a single stream from a single request.

Dave

On Sat, Sep 3, 2011 at 6:09 AM, AndyLaw <an...@roslin.ed.ac.uk> wrote:

> Indeed.
>
> I guess my question is "How best to store the results of the action so they
> can be delivered as separate parts?" - particularly the image stream which I
> would really prefer to deliver as a stream rather than fiddling about with
> temporary files on the server.
>
> On 2 Sep 2011, at 18:23, Dave Newton-6 [via Struts] wrote:
>
> Why would you need to call the DB three separate times? If you're already
> returning a JSP why wouldn't you build everything you needed from the
> action
> that processes the original submit? All you're doing is composing the
> results of a few services--no need to call actions to do that, call the
> same
> services.
>
> Dave
>
> On Fri, Sep 2, 2011 at 11:21 AM, AndyLaw <[hidden
> email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=0>> wrote:
>
> > I have an application that I need to develop that requires the following:
> >
> > Following selection by the user of the item of interest plus up and
> > downstream padding, report the locations and characteristics of features
> of
> > interest found in the region and display the data graphically with
> > clickable
> > links embedded in the image to allow navigation to further descriptions
> of
> > those features.
> >
> > So, I have a single set of inputs, (item, up and down) and I need to
> > generate three things from them.
> >
> > If I were just generating the text display, I would return "success" from
> > my
> > action and dispatch to a jsp. In fact, that seems to be the simplest
> thing
> > to do. I can then embed in the JSP code to call another action to
> generate
> > the image and one to generate the imagemap.
> >
> > But what's the best way to do that from a single database hit (rather
> than
> > fetching the same data in three separate actions)? Initial instinct says
> > "stick it in the session". Is that the best option?
> >
> > Thanks in advance for any help/suggestions you can provide.
> >
> > Later,
> >
> > Andy
> >
> >
> > --
> > View this message in context:
> >
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4762757.html
> > Sent from the Struts - User mailing list archive at Nabble.com<
> http://Nabble.com>.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden
> email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=1>
> > For additional commands, e-mail: [hidden
> email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=2>
> >
> >
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4763202.html
> To unsubscribe from Return text to jsp, plus image and imageMap from a
> single Data query?, click here<
> http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4762757&code=YW5keS5sYXdAcm9zbGluLmVkLmFjLnVrfDQ3NjI3NTd8LTEzOTMxMzMxMg==
> >.
>
> Later,
>
> Andy
> --------
> Yada, yada, yada...
>
> The University of Edinburgh is a charitable body, registered in Scotland,
> with registration number SC005336
> Disclaimer: This e-mail and any attachments are confidential and intended
> solely for the use of the recipient(s) to whom they are addressed. If you
> have received it in error, please destroy all copies and inform the sender.
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4765172.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>

Re: Return text to jsp, plus image and imageMap from a single Data query?

Posted by AndyLaw <an...@roslin.ed.ac.uk>.
Indeed.

I guess my question is "How best to store the results of the action so they can be delivered as separate parts?" - particularly the image stream which I would really prefer to deliver as a stream rather than fiddling about with temporary files on the server.

On 2 Sep 2011, at 18:23, Dave Newton-6 [via Struts] wrote:

Why would you need to call the DB three separate times? If you're already
returning a JSP why wouldn't you build everything you needed from the action
that processes the original submit? All you're doing is composing the
results of a few services--no need to call actions to do that, call the same
services.

Dave

On Fri, Sep 2, 2011 at 11:21 AM, AndyLaw <[hidden email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=0>> wrote:

> I have an application that I need to develop that requires the following:
>
> Following selection by the user of the item of interest plus up and
> downstream padding, report the locations and characteristics of features of
> interest found in the region and display the data graphically with
> clickable
> links embedded in the image to allow navigation to further descriptions of
> those features.
>
> So, I have a single set of inputs, (item, up and down) and I need to
> generate three things from them.
>
> If I were just generating the text display, I would return "success" from
> my
> action and dispatch to a jsp. In fact, that seems to be the simplest thing
> to do. I can then embed in the JSP code to call another action to generate
> the image and one to generate the imagemap.
>
> But what's the best way to do that from a single database hit (rather than
> fetching the same data in three separate actions)? Initial instinct says
> "stick it in the session". Is that the best option?
>
> Thanks in advance for any help/suggestions you can provide.
>
> Later,
>
> Andy
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4762757.html
> Sent from the Struts - User mailing list archive at Nabble.com<http://Nabble.com>.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=1>
> For additional commands, e-mail: [hidden email]<x-msg://15/user/SendEmail.jtp?type=node&node=4763202&i=2>
>
>


________________________________
If you reply to this email, your message will be added to the discussion below:
http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4763202.html
To unsubscribe from Return text to jsp, plus image and imageMap from a single Data query?, click here<http://struts.1045723.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4762757&code=YW5keS5sYXdAcm9zbGluLmVkLmFjLnVrfDQ3NjI3NTd8LTEzOTMxMzMxMg==>.

Later,

Andy
--------
Yada, yada, yada...

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336
Disclaimer: This e-mail and any attachments are confidential and intended solely for the use of the recipient(s) to whom they are addressed. If you have received it in error, please destroy all copies and inform the sender.


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



--
View this message in context: http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4765172.html
Sent from the Struts - User mailing list archive at Nabble.com.

Re: Return text to jsp, plus image and imageMap from a single Data query?

Posted by Dave Newton <da...@gmail.com>.
Why would you need to call the DB three separate times? If you're already
returning a JSP why wouldn't you build everything you needed from the action
that processes the original submit? All you're doing is composing the
results of a few services--no need to call actions to do that, call the same
services.

Dave

On Fri, Sep 2, 2011 at 11:21 AM, AndyLaw <an...@roslin.ed.ac.uk> wrote:

> I have an application that I need to develop that requires the following:
>
> Following selection by the user of the item of interest plus up and
> downstream padding, report the locations and characteristics of features of
> interest found in the region and display the data graphically with
> clickable
> links embedded in the image to allow navigation to further descriptions of
> those features.
>
> So, I have a single set of inputs, (item, up and down) and I need to
> generate three things from them.
>
> If I were just generating the text display, I would return "success" from
> my
> action and dispatch to a jsp. In fact, that seems to be the simplest thing
> to do. I can then embed in the JSP code to call another action to generate
> the image and one to generate the imagemap.
>
> But what's the best way to do that from a single database hit (rather than
> fetching the same data in three separate actions)? Initial instinct says
> "stick it in the session". Is that the best option?
>
> Thanks in advance for any help/suggestions you can provide.
>
> Later,
>
> Andy
>
>
> --
> View this message in context:
> http://struts.1045723.n5.nabble.com/Return-text-to-jsp-plus-image-and-imageMap-from-a-single-Data-query-tp4762757p4762757.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
>
>