Re: Embedding an temporary Picture into an Template

2005-03-24 Thread tarun Narang
HI
I want to send some id value from one velocity page to another VTL page 
when the user click on link(SET). 
Below is the code which i am using i want to set some variable there(in this 
href) so that i will be able to get that variable value on the next VTL page

a href=$link.setPage(somepage.vm)SET/a

and how i get the value on the next page

Thanks in advance
tarun 


RE: Embedding an temporary Picture into an Template

2005-03-23 Thread Robin Mannering
Hi Michael,

We embed images using servlets a fair bit and what we intend to do is this:

In the JSP/VM page, have a standard HTML img tag as :

img src=servlet/GetImageServlet alt=Server Side Image

The servlet that is called from within the image tag then creates the image and 
streams it directly back using an OutputStream.

Hope this helps

Robin


-Original Message-
From: Michael Belz [mailto:[EMAIL PROTECTED]
Sent: 23 March 2005 11:35
To: velocity-user@jakarta.apache.org
Subject: Embedding an temporary Picture into an Template


Hi,

I'm trying to put a graphic into an Velocity Template (vm).
The problem is that the servelt generated graphic should not be 
physically saved to an temporary folder on the server. It's an 
encoded jpeg stored in a bytearray. When I use the servlet path
at an 'img src'-tag the graphic is shown. But I don't have this
option here. I already tried to add the bytearray to the context
by using the method put() but then I only get the hash of the 
bytearray (because of the toString() method I guess).

Here's my code:
--
public void perform(Context context, HttpServletRequest request,
HttpServletResponse response, Properties initProps,
Properties sessionProps) throws IOException {

super.perform(context, request, response);
HttpSession session =request.getSession();


double[] data = new double[7];
for (int i = 0; i  data.length; i++){
data[i] = Math.random() * 15;
}

BarChart chart = new BarChart(600,1999,data);


response.setContentType(image/jpeg);
String strFileName = test.jpg;
  OutputStream imageout = response.getOutputStream(); 
imageout.write(chart.getJpegByteArray());
//context.put(trigger,chart.getJpegByteArray());//
doesn't Work

}
--

When I put the Image directly onto the response outputstream, the
picture is shown.
But ONLY the picture. I need to add some additional HTML Code around it.
Like I said
context.put() doesn't work.

Can anybody help me out?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this e-mail and you are not a named
addressee, please inform Landmark Information Group on 01491 413030
and then delete the e-mail from your system. If you are not a named
addressee you must not use, disclose, distribute, copy, print or rely 
on this e-mail. This email and any attachments have been scanned for
viruses and to the best of our knowledge are clean. To ensure 
regulatory compliance and for the protection of our clients and 
business, we may monitor and read e-mails sent to and from our 
servers.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Embedding an temporary Picture into an Template

2005-03-23 Thread Michael Belz
Hi Robin thx for you answer!

I know this way to do it. The problem is that the guys here
have written their own dispatcher servlet so that I can't
access the picture that way. I also need to do a few SQL
statements first so that I use a controller I wrote that
collects all the data needed and then generates a bar chart.


Michael


-Ursprüngliche Nachricht-
Von: Robin Mannering [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 23. März 2005 12:43
An: Velocity Users List
Betreff: RE: Embedding an temporary Picture into an Template

Hi Michael,

We embed images using servlets a fair bit and what we intend to do is
this:

In the JSP/VM page, have a standard HTML img tag as :

img src=servlet/GetImageServlet alt=Server Side Image

The servlet that is called from within the image tag then creates the
image and streams it directly back using an OutputStream.

Hope this helps

Robin


-Original Message-
From: Michael Belz [mailto:[EMAIL PROTECTED]
Sent: 23 March 2005 11:35
To: velocity-user@jakarta.apache.org
Subject: Embedding an temporary Picture into an Template


Hi,

I'm trying to put a graphic into an Velocity Template (vm).
The problem is that the servelt generated graphic should not be 
physically saved to an temporary folder on the server. It's an 
encoded jpeg stored in a bytearray. When I use the servlet path
at an 'img src'-tag the graphic is shown. But I don't have this
option here. I already tried to add the bytearray to the context
by using the method put() but then I only get the hash of the 
bytearray (because of the toString() method I guess).

Here's my code:
--
public void perform(Context context, HttpServletRequest request,
HttpServletResponse response, Properties initProps,
Properties sessionProps) throws IOException {

super.perform(context, request, response);
HttpSession session =request.getSession();


double[] data = new double[7];
for (int i = 0; i  data.length; i++){
data[i] = Math.random() * 15;
}

BarChart chart = new BarChart(600,1999,data);


response.setContentType(image/jpeg);
String strFileName = test.jpg;
  OutputStream imageout = response.getOutputStream(); 
imageout.write(chart.getJpegByteArray());
//context.put(trigger,chart.getJpegByteArray());//
doesn't Work

}
--

When I put the Image directly onto the response outputstream, the
picture is shown.
But ONLY the picture. I need to add some additional HTML Code around it.
Like I said
context.put() doesn't work.

Can anybody help me out?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this e-mail and you are not a named
addressee, please inform Landmark Information Group on 01491 413030
and then delete the e-mail from your system. If you are not a named
addressee you must not use, disclose, distribute, copy, print or rely 
on this e-mail. This email and any attachments have been scanned for
viruses and to the best of our knowledge are clean. To ensure 
regulatory compliance and for the protection of our clients and 
business, we may monitor and read e-mails sent to and from our 
servers.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Embedding an temporary Picture into an Template

2005-03-23 Thread Meikel Bisping
Hi Michael,

if you find a solution let me know.
In a different context I create temp graphic files and used a
FileDeleterThread to delete them again after 300 secs.

e.g.
Vector tmpFiles=new Vector();
tmpFiles.add(f1);
FileDeleterThread fd = new FileDeleterThread(tmpFiles, 300);
 fd.start();


Maybe that helps.

Cheers,

Meikel

-
import java.io.File;
import java.util.Collection;
import java.util.Iterator;

/**
 * Deletes a collection of files after a given amount of seconds
 */
public class FileDeleterThread extends Thread {
private Collection files;
private int secs;

public FileDeleterThread(Collection files, int secs) {
this.files = files;
this.secs = secs;
}

public void run() {
try {
Thread.sleep(secs * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
for (Iterator it = files.iterator(); it.hasNext();) {
File f = (File) it.next();
f.delete();
}
}

}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Embedding an temporary Picture into an Template

2005-03-23 Thread Christoph Reck
Hi,
since your code snippet works for 1 image, then you can refer to
this URL from another veloctity generated HTML pages using the
img src=... element. The browser will then open additional
connections to your server and retrieve the image(s).
You may have the problem that HTML generating servlet also
generates the image. Here you can store the image in the servlet
application context or in some other static caching tool, this
allows you to retrieve the data in separate http connections
(from a properly configured servlet).
If you only want to embed small graphics in a page, the embedded
data URL scheme: http://www.faqs.org/rfcs/rfc2397.html
and http://www.elf.org/essay/inline-image.html may be a solution.
Note the restriction to about 1024 bytes.
Another solution, but with higher overhead, would be to render
the whole generated HTML page (with embeded images) into a GIF/PNG
with something like FOP (see xml.apache.org), and send only this
super-image to the browser.
Within an email, you can use a multi-part message to add any size
images to be displayed inline in an HTML-coded email. With plain
HTML browsers this is not availabe. Here you can only use the
img-tag or JavaScript to feed in the image into the page. If all
is to be done within one HTTP connection, you might consider
using the HTTP keep-alive feature.
You seem to understand the problem, but are asking if anyone has
a realy bright solution. If something is not clear, or your need
some pointers, or you're sure that there might be other solutions,
you can re-ask on this thread.
Cheers,
:) Christoph Reck
Michael Belz wrote:
Hi,
I'm trying to put a graphic into an Velocity Template (vm).
The problem is that the servelt generated graphic should not be 
physically saved to an temporary folder on the server. It's an 
encoded jpeg stored in a bytearray. When I use the servlet path
at an 'img src'-tag the graphic is shown. But I don't have this
option here. I already tried to add the bytearray to the context
by using the method put() but then I only get the hash of the 
bytearray (because of the toString() method I guess).

Here's my code:
--
public void perform(Context context, HttpServletRequest request,
HttpServletResponse response, Properties initProps,
Properties sessionProps) throws IOException {

super.perform(context, request, response);
HttpSession session =request.getSession();

double[] data = new double[7];
for (int i = 0; i  data.length; i++){
data[i] = Math.random() * 15;
}

BarChart chart = new BarChart(600,1999,data);
	
		response.setContentType(image/jpeg);
		String strFileName = test.jpg;
	  OutputStream imageout = response.getOutputStream(); 
		imageout.write(chart.getJpegByteArray());
		//context.put(trigger,chart.getJpegByteArray());//
doesn't Work	

	}
--

When I put the Image directly onto the response outputstream, the
picture is shown.
But ONLY the picture. I need to add some additional HTML Code around it.
Like I said
context.put() doesn't work.
Can anybody help me out?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Embedding an temporary Picture into an Template

2005-03-23 Thread Christoph . Reck
Hi,
since your code snippet works for 1 image, then you can refer to
this URL from another veloctity generated HTML pages using the
img src=... element. The browser will then open additional
connections to your server and retrieve the image(s).
You may have the problem that HTML generating servlet also
generates the image. Here you can store the image in the servlet
application context or in some other static caching tool, this
allows you to retrieve the data in separate http connections
(from a properly configured servlet).
If you only want to embed small graphics in a page, the embedded
data URL scheme: http://www.faqs.org/rfcs/rfc2397.html
and http://www.elf.org/essay/inline-image.html may be a solution.
Note the restriction to about 1024 bytes.
Another solution, but with higher overhead, would be to render
the whole generated HTML page (with embeded images) into a GIF/PNG
with something like FOP (see xml.apache.org), and send only this
super-image to the browser.
Within an email, you can use a multi-part message to add any size
images to be displayed inline in an HTML-coded email. With plain
HTML browsers this is not availabe. Here you can only use the
img-tag or JavaScript to feed in the image into the page. If all
is to be done within one HTTP connection, you might consider
using the HTTP keep-alive feature.
You seem to understand the problem, but are asking if anyone has
a realy bright solution. If something is not clear, or your need
some pointers, or you're sure that there might be other solutions,
you can re-ask on this thread.
Cheers,
:) Christoph Reck
Michael Belz wrote:
Hi,
I'm trying to put a graphic into an Velocity Template (vm).
The problem is that the servelt generated graphic should not be 
physically saved to an temporary folder on the server. It's an 
encoded jpeg stored in a bytearray. When I use the servlet path
at an 'img src'-tag the graphic is shown. But I don't have this
option here. I already tried to add the bytearray to the context
by using the method put() but then I only get the hash of the 
bytearray (because of the toString() method I guess).

Here's my code:
--
public void perform(Context context, HttpServletRequest request,
HttpServletResponse response, Properties initProps,
Properties sessionProps) throws IOException {

super.perform(context, request, response);
HttpSession session =request.getSession();

double[] data = new double[7];
for (int i = 0; i  data.length; i++){
data[i] = Math.random() * 15;
}

BarChart chart = new BarChart(600,1999,data);
	
		response.setContentType(image/jpeg);
		String strFileName = test.jpg;
	  OutputStream imageout = response.getOutputStream(); 
		imageout.write(chart.getJpegByteArray());
		//context.put(trigger,chart.getJpegByteArray());//
doesn't Work	

	}
--

When I put the Image directly onto the response outputstream, the
picture is shown.
But ONLY the picture. I need to add some additional HTML Code around it.
Like I said
context.put() doesn't work.
Can anybody help me out?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]