You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andy Wagg <an...@virgin.net> on 2002/08/30 00:00:49 UTC

Where should i put dynamically generated graphics

Hello

I have a web application that generates a gif file that is then 
subsequently displayed. It expects to find the gif file in the context 
of the web application. The web app is deployed as a war so obviously 
the generated files cant be put there. Any suggestions as to where these 
files could be copied that would be accesible by the browser.

Thanks in advance.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Where should i put dynamically generated graphics

Posted by Felipe Schnack <fe...@ritterdosreis.br>.
  Yes, I would like the solution where we can write to the servlet
outputstream, but I have no idea how to do it.

On Fri, 2002-08-30 at 10:21, Michael E. Locasto wrote:
> I can think of a couple of ways offhand:
> 
>     -process the request
>     -generate your image
>     -store your image somewhere (optional)
>     - either
>         - write the image directly out to the servlet's underlying
> outputstream
>         as a buffered byte output stream (I don't think PrintWriter would be
> appropriate. This would probably also in involve a
> "response.setContentType("image/gif"); ... but i've never done this, so I'm
> probably wrong.)
> 
>     -or-
> 
>         -store your image somewhere
>         -return html that has a bunch of <img src=""> tags or hyperlinks to
> the images
>         eg:
>         /* get my images! */
>   public void doGet(HttpServletRequest request,
>                       HttpServletResponse response)
>       throws IOException, ServletException {
>     /* optionally clean out the temp image directory */
>     /* genrt imgs, store in gen_images/username/ under the current context
> */
> 
>  response.setContentType("text/html");
>  PrintWriter out = response.getWriter();
>   out.println( "<html><body>" );
>   out.println( "<img src=\"gen_images/username/foo.gif\" >" );
>   out.println( "<img src=\"gen_images/username/foo1.gif\" >" );
>   out.println( "<img src=\"gen_images/username/foo2.gif\" >" );
>   out.println( "</body></html>" );
> }
> 
> of course, feel free to spruce that html up ;)
> 
> hope that helps,
> Michael
> 
> ----- Original Message -----
> From: "Felipe Schnack" <fe...@ritterdosreis.br>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Friday, August 30, 2002 8:06 AM
> Subject: RE: Where should i put dynamically generated graphics
> 
> 
> >   How can I return an image from a servlet??
> >
> > On Thu, 2002-08-29 at 20:05, Sexton, George wrote:
> > > It depends. One way I have done it is to have the generator servlet save
> it
> > > on the session, and have the page the generator servlet writes make a
> > > request to a simple servlet that returns the graphic, and then deletes
> it
> > > from the session.
> > >
> > > Another way would be to write it to the temp dir. From the Servlet API
> Spec:
> > >
> > > SRV.3.7.1 Temporary Working Directories
> > > A temporary storage directory is required for each servlet context.
> Servlet
> > > containers must provide a private temporary directory per servlet
> context,
> > > and make
> > > it available via the javax.servlet.context.tempdir context attribute.
> The
> > > objects
> > > associated with the attribute must be of type java.io.File.
> > >
> > > Then, using a servlet mapping request the generated image and have the
> > > servlet retrieve the temporary image.
> > >
> > > I guess that you could make another dir writable to the server, and
> store
> > > the image in their natively.
> > >
> > > George Sexton
> > > MH Software, Inc.
> > > Home of Connect Daily Web Calendar Software
> > > http://www.mhsoftware.com/connectdaily.htm
> > > Voice: 303 438 9585
> > >
> > >
> > > -----Original Message-----
> > > From: Andy Wagg [mailto:andrew.wagg@virgin.net]
> > > Sent: 29 August, 2002 4:01 PM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: Where should i put dynamically generated graphics
> > >
> > >
> > > Hello
> > >
> > > I have a web application that generates a gif file that is then
> > > subsequently displayed. It expects to find the gif file in the context
> > > of the web application. The web app is deployed as a war so obviously
> > > the generated files cant be put there. Any suggestions as to where these
> > > files could be copied that would be accesible by the browser.
> > >
> > > Thanks in advance.
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > >
> > --
> >
> > Felipe Schnack
> > Analista de Sistemas
> > felipes@ritterdosreis.br
> > Cel.: (51)91287530
> > Linux Counter #281893
> >
> > Faculdade Ritter dos Reis
> > www.ritterdosreis.br
> > felipes@ritterdosreis.br
> > Fone/Fax.: (51)32303328
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
-- 

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Where should i put dynamically generated graphics

Posted by "Michael E. Locasto" <lo...@cs.columbia.edu>.
I can think of a couple of ways offhand:

    -process the request
    -generate your image
    -store your image somewhere (optional)
    - either
        - write the image directly out to the servlet's underlying
outputstream
        as a buffered byte output stream (I don't think PrintWriter would be
appropriate. This would probably also in involve a
"response.setContentType("image/gif"); ... but i've never done this, so I'm
probably wrong.)

    -or-

        -store your image somewhere
        -return html that has a bunch of <img src=""> tags or hyperlinks to
the images
        eg:
        /* get my images! */
  public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
      throws IOException, ServletException {
    /* optionally clean out the temp image directory */
    /* genrt imgs, store in gen_images/username/ under the current context
*/

 response.setContentType("text/html");
 PrintWriter out = response.getWriter();
  out.println( "<html><body>" );
  out.println( "<img src=\"gen_images/username/foo.gif\" >" );
  out.println( "<img src=\"gen_images/username/foo1.gif\" >" );
  out.println( "<img src=\"gen_images/username/foo2.gif\" >" );
  out.println( "</body></html>" );
}

of course, feel free to spruce that html up ;)

hope that helps,
Michael

----- Original Message -----
From: "Felipe Schnack" <fe...@ritterdosreis.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, August 30, 2002 8:06 AM
Subject: RE: Where should i put dynamically generated graphics


>   How can I return an image from a servlet??
>
> On Thu, 2002-08-29 at 20:05, Sexton, George wrote:
> > It depends. One way I have done it is to have the generator servlet save
it
> > on the session, and have the page the generator servlet writes make a
> > request to a simple servlet that returns the graphic, and then deletes
it
> > from the session.
> >
> > Another way would be to write it to the temp dir. From the Servlet API
Spec:
> >
> > SRV.3.7.1 Temporary Working Directories
> > A temporary storage directory is required for each servlet context.
Servlet
> > containers must provide a private temporary directory per servlet
context,
> > and make
> > it available via the javax.servlet.context.tempdir context attribute.
The
> > objects
> > associated with the attribute must be of type java.io.File.
> >
> > Then, using a servlet mapping request the generated image and have the
> > servlet retrieve the temporary image.
> >
> > I guess that you could make another dir writable to the server, and
store
> > the image in their natively.
> >
> > George Sexton
> > MH Software, Inc.
> > Home of Connect Daily Web Calendar Software
> > http://www.mhsoftware.com/connectdaily.htm
> > Voice: 303 438 9585
> >
> >
> > -----Original Message-----
> > From: Andy Wagg [mailto:andrew.wagg@virgin.net]
> > Sent: 29 August, 2002 4:01 PM
> > To: tomcat-user@jakarta.apache.org
> > Subject: Where should i put dynamically generated graphics
> >
> >
> > Hello
> >
> > I have a web application that generates a gif file that is then
> > subsequently displayed. It expects to find the gif file in the context
> > of the web application. The web app is deployed as a war so obviously
> > the generated files cant be put there. Any suggestions as to where these
> > files could be copied that would be accesible by the browser.
> >
> > Thanks in advance.
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> --
>
> Felipe Schnack
> Analista de Sistemas
> felipes@ritterdosreis.br
> Cel.: (51)91287530
> Linux Counter #281893
>
> Faculdade Ritter dos Reis
> www.ritterdosreis.br
> felipes@ritterdosreis.br
> Fone/Fax.: (51)32303328
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Where should i put dynamically generated graphics

Posted by Felipe Schnack <fe...@ritterdosreis.br>.
  How can I return an image from a servlet??

On Thu, 2002-08-29 at 20:05, Sexton, George wrote:
> It depends. One way I have done it is to have the generator servlet save it
> on the session, and have the page the generator servlet writes make a
> request to a simple servlet that returns the graphic, and then deletes it
> from the session.
> 
> Another way would be to write it to the temp dir. From the Servlet API Spec:
> 
> SRV.3.7.1 Temporary Working Directories
> A temporary storage directory is required for each servlet context. Servlet
> containers must provide a private temporary directory per servlet context,
> and make
> it available via the javax.servlet.context.tempdir context attribute. The
> objects
> associated with the attribute must be of type java.io.File.
> 
> Then, using a servlet mapping request the generated image and have the
> servlet retrieve the temporary image.
> 
> I guess that you could make another dir writable to the server, and store
> the image in their natively.
> 
> George Sexton
> MH Software, Inc.
> Home of Connect Daily Web Calendar Software
> http://www.mhsoftware.com/connectdaily.htm
> Voice: 303 438 9585
> 
> 
> -----Original Message-----
> From: Andy Wagg [mailto:andrew.wagg@virgin.net]
> Sent: 29 August, 2002 4:01 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Where should i put dynamically generated graphics
> 
> 
> Hello
> 
> I have a web application that generates a gif file that is then
> subsequently displayed. It expects to find the gif file in the context
> of the web application. The web app is deployed as a war so obviously
> the generated files cant be put there. Any suggestions as to where these
> files could be copied that would be accesible by the browser.
> 
> Thanks in advance.
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
-- 

Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893

Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Where should i put dynamically generated graphics

Posted by "Sexton, George" <gs...@mhsoftware.com>.
It depends. One way I have done it is to have the generator servlet save it
on the session, and have the page the generator servlet writes make a
request to a simple servlet that returns the graphic, and then deletes it
from the session.

Another way would be to write it to the temp dir. From the Servlet API Spec:

SRV.3.7.1 Temporary Working Directories
A temporary storage directory is required for each servlet context. Servlet
containers must provide a private temporary directory per servlet context,
and make
it available via the javax.servlet.context.tempdir context attribute. The
objects
associated with the attribute must be of type java.io.File.

Then, using a servlet mapping request the generated image and have the
servlet retrieve the temporary image.

I guess that you could make another dir writable to the server, and store
the image in their natively.

George Sexton
MH Software, Inc.
Home of Connect Daily Web Calendar Software
http://www.mhsoftware.com/connectdaily.htm
Voice: 303 438 9585


-----Original Message-----
From: Andy Wagg [mailto:andrew.wagg@virgin.net]
Sent: 29 August, 2002 4:01 PM
To: tomcat-user@jakarta.apache.org
Subject: Where should i put dynamically generated graphics


Hello

I have a web application that generates a gif file that is then
subsequently displayed. It expects to find the gif file in the context
of the web application. The web app is deployed as a war so obviously
the generated files cant be put there. Any suggestions as to where these
files could be copied that would be accesible by the browser.

Thanks in advance.


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>