Re: Displaying images from database (BLOB) using the tag

2011-05-16 Thread Maurizio Cucchiara
Take a look at http://struts.apache.org/2.x/docs/stream-result.html

On 16 May 2011 18:41, Ilya Kazakevich  wrote:
> You need action (or servlet) that will read image from db and write image to
> the output stream setting appropriate conent-type.
> Than you do: 
>
>
>
>
>
> Ilya Kazakevich,
> Developer
> JetBrains Inc
> http://www.jetbrains.com
> "Develop with pleasure!"
>
> -Original Message-
> From: Saeed Najahi [mailto:najah...@gmail.com]
> Sent: Monday, May 16, 2011 7:48 PM
> To: user@struts.apache.org
> Subject: Displaying images from database (BLOB) using the  tag
>
> hello guys, can anyone kindly tell me how can i display an image fetched
> from a database using the  tag? thanks in advance.
>
> --
> 
> 
> `*The early bird catches the worm, but the second mouse gets the cheese..*`
>
> *NAJAHI Saïd* (* KyouJin-SaMa* )
> 4ème année G.Info E.N.S.A.Safi
> 
> -
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



-- 
Maurizio Cucchiara

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



RE: Displaying images from database (BLOB) using the tag

2011-05-16 Thread Ilya Kazakevich
You need action (or servlet) that will read image from db and write image to
the output stream setting appropriate conent-type.
Than you do: 


 


Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
"Develop with pleasure!"

-Original Message-
From: Saeed Najahi [mailto:najah...@gmail.com] 
Sent: Monday, May 16, 2011 7:48 PM
To: user@struts.apache.org
Subject: Displaying images from database (BLOB) using the  tag

hello guys, can anyone kindly tell me how can i display an image fetched
from a database using the  tag? thanks in advance.

-- 


`*The early bird catches the worm, but the second mouse gets the cheese..*`

*NAJAHI Saïd* (* KyouJin-SaMa* )
4ème année G.Info E.N.S.A.Safi

-


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



Re: Displaying images from database (BLOB) using the tag

2011-05-16 Thread Chris Pratt
Stream it to the ServletOutputStream and return null from the action.
  (*Chris*)
On May 16, 2011 8:48 AM, "Saeed Najahi"  wrote:
> hello guys, can anyone kindly tell me how can i display an image fetched
> from a database using the  tag? thanks in advance.
>
> --
>

> `*The early bird catches the worm, but the second mouse gets the
cheese..*`
>
> *NAJAHI Saïd* (* KyouJin-SaMa* )
> 4ème année G.Info E.N.S.A.Safi
>
-


Displaying images from database (BLOB) using the tag

2011-05-16 Thread Saeed Najahi
hello guys, can anyone kindly tell me how can i display an image fetched
from a database using the  tag? thanks in advance.

-- 

`*The early bird catches the worm, but the second mouse gets the cheese..*`

*NAJAHI Saïd* (* KyouJin-SaMa* )
4ème année G.Info E.N.S.A.Safi
-


Re: Displaying images from database.

2006-07-25 Thread Niall Pemberton

Struts has a download action which can help with this:

http://wiki.apache.org/struts/StrutsFileDownload

Niall

On 7/25/06, Martin Gainty <[EMAIL PROTECTED]> wrote:

2 possibly ways
http://www.velocityreviews.com/forums/t135655-help-sessions-images-amp-beans-no-cookies-please.html

Anyone else?

M-

- Original Message -
From: "C. Grobmeier" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Tuesday, July 25, 2006 9:55 AM
Subject: Re: Displaying images from database.


> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Then how can one have an Java-Object, let's say Person.java. Person has
> a property called 'avatare' which can be get with "File getAvatar()".
> Can i do something like  or so?
>
> Btw- this isn't really good practice, is it? The example below seems
> good for an Ajax request but i am not sure if i should store my images
> as a blob.
>
> chris
>
> Thomas Joseph wrote:
>> Hi Prerna,
>>
>> Use the Action Class for the image display solely for image display. When the browser executes 
the   tag, it is basically giving a 
saparate request to your action class that generates the image.  Notice that the action class returns 
null, which means that the action class will render the response itself and will not forward to any JSP 
page.  The remaining protions of your JSP will be generated by other Action Class forwards as usual.
>>
>> Hope this helps to understand better.
>>
>> Thanks and Regards,
>> Thomas Joseph
>>
>> Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin-682015 | 
India
>> www.kottsoftware.com
>> 

>> This email (including any attachments) is subject to copyright, the 
information in it is confidential, and it is legally privileged. Use of this email or 
of any information in it other than by the addressee is unauthorized and unlawful. If 
you are not the intended recipient of the mail, kindly intimate the author of the 
mail and delete the same.
>> 
------------
>>
>>   - Original Message -
>>   From: [EMAIL PROTECTED]
>>   To: user@struts.apache.org
>>   Sent: Tuesday, July 25, 2006 6:37 PM
>>   Subject: RE: Displaying images from database.
>>
>>
>>
>>   Hi David
>>
>>   Thanks for a prompt response.
>>
>>   But I also want to display other things on the jsp page besides the
>>   image.
>>   For e.g.
>>
>>   My jsp page would have
>>
>>   Company name, Address, Business Area and its logo with an EDIT button
>>   and when the user clicks on the EDIT button he can update Address
>>   information and save the changes made
>>
>>   How can I achieve this?
>>
>>   Thanks & Regards
>>   Prerna
>>
>>   -Original Message-
>>   From: David Soler [mailto:[EMAIL PROTECTED]
>>   Sent: Tuesday, July 25, 2006 6:43 PM
>>   To: Struts Users Mailing List
>>   Subject: RE: Displaying images from database.
>>
>>   Try the following:
>>
>>   /*** JSP file /
>>
>>   <%@ taglib uri="/tags/struts-html" prefix="html" %>
>>   
>>   
>>   
>>   
>>   
>>   <%
>>   HashMap params = new HashMap();
>>   params.put("ID", request.getParameter("ID"));
>>   pageContext.setAttribute("params", params);
>>   %>
>>   
>>   
>>   
>>
>>
>>   /*** Action class */
>>
>>   import javax.servlet.http.HttpServletRequest;
>>   import javax.servlet.http.HttpServletResponse;
>>   import javax.servlet.http.HttpSession;
>>   import javax.servlet.*;
>>   import org.apache.struts.action.Action;
>>   import org.apache.struts.action.ActionForm;
>>   import org.apache.struts.action.ActionForward;
>>   import org.apache.struts.action.ActionMapping;
>>
>>   public class GetImageAction extends Action {
>>   public ActionForward execute(
>>   ActionMapping mapping,
>>   ActionForm form,
>>   HttpServletRequest request,
>>   HttpServletResponse response) throws Exception{
>>
>>   byte[] b;
>>
>>   //Here the code to take the image from the database (you
>>   need the parameter ID).
>>   //Put the bytes into array b[]
>>
>>   //response.setContentType("image/gif"); //it's not
>>   necessary
>>   ServletOutputStream sout = response.getOutputStream();
>>
>>   sout.write(b);
>>   sout.flush();
>>   sout.close();
>>
>>   return null;
>>   }
>>   }
>>
>>   David
>>
>>
>>
>>   -Mensaje original-
>>   De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>>   Enviado el: martes, 25 de julio de 2006 14:34
>>   Para: user@struts.apache.org
>>   Asunto: Displaying images from database.
>>
>>
>>   Hi All,
>>
>>
>>
>>
>>   My application saves the images in database as BLOB. I now want to
>>   display these images stored in my database. How can I do this in struts
>>   2.0 ?
>>
>>
>>
>>
>>   Thanks & Regards
>>
>>   Prerna


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



Re: Displaying images from database.

2006-07-25 Thread C. Grobmeier
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Is it good practice to store images in a database for webapplications? I
allways thougth space is better.

Thanks for your answer and the link

Martin Gainty wrote:
> 2 possibly ways
>  
> OR 
> 
>  
> take a look at
> http://www.velocityreviews.com/forums/t135655-help-sessions-images-amp-beans-no-cookies-please.html
> 
> Anyone else?
> M-
> *
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
> 
> 
> 
> - Original Message - 
> From: "C. Grobmeier" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" 
> Sent: Tuesday, July 25, 2006 9:55 AM
> Subject: Re: Displaying images from database.
> 
> 
> Then how can one have an Java-Object, let's say Person.java. Person has
> a property called 'avatare' which can be get with "File getAvatar()".
> Can i do something like  or so?
> 
> Btw- this isn't really good practice, is it? The example below seems
> good for an Ajax request but i am not sure if i should store my images
> as a blob.
> 
> chris
> 
> Thomas Joseph wrote:
>>>> Hi Prerna,
>>>>
>>>> Use the Action Class for the image display solely for image display. When 
>>>> the browser executes the   
>>>> tag, it is basically giving a saparate request to your action class that 
>>>> generates the image.  Notice that the action class returns null, which 
>>>> means that the action class will render the response itself and will not 
>>>> forward to any JSP page.  The remaining protions of your JSP will be 
>>>> generated by other Action Class forwards as usual.
>>>>
>>>> Hope this helps to understand better.
>>>>
>>>> Thanks and Regards,
>>>> Thomas Joseph 
>>>>
>>>> Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin-682015 | 
>>>> India 
>>>> www.kottsoftware.com 
>>>> 
>>>> This email (including any attachments) is subject to copyright, the 
>>>> information in it is confidential, and it is legally privileged. Use of 
>>>> this email or of any information in it other than by the addressee is 
>>>> unauthorized and unlawful. If you are not the intended recipient of the 
>>>> mail, kindly intimate the author of the mail and delete the same. 
>>>> 
>>>>
>>>>   - Original Message - 
>>>>   From: [EMAIL PROTECTED] 
>>>>   To: user@struts.apache.org 
>>>>   Sent: Tuesday, July 25, 2006 6:37 PM
>>>>   Subject: RE: Displaying images from database.
>>>>
>>>>
>>>>
>>>>   Hi David
>>>>
>>>>   Thanks for a prompt response.
>>>>
>>>>   But I also want to display other things on the jsp page besides the
>>>>   image.
>>>>   For e.g.
>>>>
>>>>   My jsp page would have
>>>>
>>>>   Company name, Address, Business Area and its logo with an EDIT button
>>>>   and when the user clicks on the EDIT button he can update Address
>>>>   information and save the changes made
>>>>
>>>>   How can I achieve this?
>>>>
>>>>   Thanks & Regards
>>>>   Prerna
>>>>
>>>>   -Original Message-
>>>>   From: David Soler [mailto:[EMAIL PROTECTED]
>>>>   Sent: Tuesday, July 25, 2006 6:43 PM
>>>>   To: Struts Users Mailing List
>>>>   Subject: RE: Displaying images from database.
>>>>
>>>>   Try the following:
>>>>
>>>>   /*** JSP file /
>>>>
>>>>   <%@ taglib uri="/tags/struts-html" prefix="html" %>
>>>>   
>>>>   
>>>>   
>>>>   
>>>>   
>>>>   <%
>>>>   HashMap params = new HashMap();
>>>>   params.put("ID", request.getParameter("ID"));
>>>>   pageContext.set

Re: Displaying images from database.

2006-07-25 Thread Martin Gainty
2 possibly ways
http://www.velocityreviews.com/forums/t135655-help-sessions-images-amp-beans-no-cookies-please.html

Anyone else?
M-
*
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



- Original Message - 
From: "C. Grobmeier" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Tuesday, July 25, 2006 9:55 AM
Subject: Re: Displaying images from database.


> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Then how can one have an Java-Object, let's say Person.java. Person has
> a property called 'avatare' which can be get with "File getAvatar()".
> Can i do something like  or so?
> 
> Btw- this isn't really good practice, is it? The example below seems
> good for an Ajax request but i am not sure if i should store my images
> as a blob.
> 
> chris
> 
> Thomas Joseph wrote:
>> Hi Prerna,
>> 
>> Use the Action Class for the image display solely for image display. When 
>> the browser executes the   
>> tag, it is basically giving a saparate request to your action class that 
>> generates the image.  Notice that the action class returns null, which means 
>> that the action class will render the response itself and will not forward 
>> to any JSP page.  The remaining protions of your JSP will be generated by 
>> other Action Class forwards as usual.
>> 
>> Hope this helps to understand better.
>> 
>> Thanks and Regards,
>> Thomas Joseph 
>> 
>> Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin-682015 | 
>> India 
>> www.kottsoftware.com 
>> 
>> This email (including any attachments) is subject to copyright, the 
>> information in it is confidential, and it is legally privileged. Use of this 
>> email or of any information in it other than by the addressee is 
>> unauthorized and unlawful. If you are not the intended recipient of the 
>> mail, kindly intimate the author of the mail and delete the same. 
>> --------
>> 
>>   - Original Message - 
>>   From: [EMAIL PROTECTED] 
>>   To: user@struts.apache.org 
>>   Sent: Tuesday, July 25, 2006 6:37 PM
>>   Subject: RE: Displaying images from database.
>> 
>> 
>> 
>>   Hi David
>> 
>>   Thanks for a prompt response.
>> 
>>   But I also want to display other things on the jsp page besides the
>>   image.
>>   For e.g.
>> 
>>   My jsp page would have
>> 
>>   Company name, Address, Business Area and its logo with an EDIT button
>>   and when the user clicks on the EDIT button he can update Address
>>   information and save the changes made
>> 
>>   How can I achieve this?
>> 
>>   Thanks & Regards
>>   Prerna
>> 
>>   -Original Message-
>>   From: David Soler [mailto:[EMAIL PROTECTED]
>>   Sent: Tuesday, July 25, 2006 6:43 PM
>>   To: Struts Users Mailing List
>>   Subject: RE: Displaying images from database.
>> 
>>   Try the following:
>> 
>>   /*** JSP file /
>> 
>>   <%@ taglib uri="/tags/struts-html" prefix="html" %>
>>   
>>   
>>   
>>   
>>   
>>   <%
>>   HashMap params = new HashMap();
>>   params.put("ID", request.getParameter("ID"));
>>   pageContext.setAttribute("params", params);
>>   %>
>>   
>>   
>>   
>> 
>> 
>>   /*** Action class */
>> 
>>   import javax.servlet.http.HttpServletRequest;
>>   import javax.servlet.http.HttpServletResponse;
>>   import javax.servlet.http.HttpSession;
>>   import javax.servlet.*;
>>   import org.apache.struts.action.Action;
>>   import org.apache.struts.action.ActionForm;
>>   import org.apache.struts.action.ActionForward;
>>   import org.apache.struts.action.ActionMapping;
>> 
>>   public class GetImageAction extends Action {
>>   public ActionForward execute(
>>   ActionMapping mapping,
>>   ActionForm form,
>>   HttpServletRequest request,
>>   HttpServletResponse response) throws Exception{
>> 
>

Re: Displaying images from database.

2006-07-25 Thread C. Grobmeier
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Then how can one have an Java-Object, let's say Person.java. Person has
a property called 'avatare' which can be get with "File getAvatar()".
Can i do something like  or so?

Btw- this isn't really good practice, is it? The example below seems
good for an Ajax request but i am not sure if i should store my images
as a blob.

chris

Thomas Joseph wrote:
> Hi Prerna,
> 
> Use the Action Class for the image display solely for image display. When the 
> browser executes the   tag, it 
> is basically giving a saparate request to your action class that generates 
> the image.  Notice that the action class returns null, which means that the 
> action class will render the response itself and will not forward to any JSP 
> page.  The remaining protions of your JSP will be generated by other Action 
> Class forwards as usual.
> 
> Hope this helps to understand better.
> 
> Thanks and Regards,
> Thomas Joseph 
> 
> Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin-682015 | 
> India 
> www.kottsoftware.com 
> 
> This email (including any attachments) is subject to copyright, the 
> information in it is confidential, and it is legally privileged. Use of this 
> email or of any information in it other than by the addressee is unauthorized 
> and unlawful. If you are not the intended recipient of the mail, kindly 
> intimate the author of the mail and delete the same. 
> 
> 
>   - Original Message - 
>   From: [EMAIL PROTECTED] 
>   To: user@struts.apache.org 
>   Sent: Tuesday, July 25, 2006 6:37 PM
>   Subject: RE: Displaying images from database.
> 
> 
> 
>   Hi David
> 
>   Thanks for a prompt response.
> 
>   But I also want to display other things on the jsp page besides the
>   image.
>   For e.g.
> 
>   My jsp page would have
> 
>   Company name, Address, Business Area and its logo with an EDIT button
>   and when the user clicks on the EDIT button he can update Address
>   information and save the changes made
> 
>   How can I achieve this?
> 
>   Thanks & Regards
>   Prerna
> 
>   -----Original Message-
>   From: David Soler [mailto:[EMAIL PROTECTED]
>   Sent: Tuesday, July 25, 2006 6:43 PM
>   To: Struts Users Mailing List
>   Subject: RE: Displaying images from database.
> 
>   Try the following:
> 
>   /*** JSP file /
> 
>   <%@ taglib uri="/tags/struts-html" prefix="html" %>
>   
>   
>   
>   
>   
>   <%
>   HashMap params = new HashMap();
>   params.put("ID", request.getParameter("ID"));
>   pageContext.setAttribute("params", params);
>   %>
>   
>   
>   
> 
> 
>   /*** Action class */
> 
>   import javax.servlet.http.HttpServletRequest;
>   import javax.servlet.http.HttpServletResponse;
>   import javax.servlet.http.HttpSession;
>   import javax.servlet.*;
>   import org.apache.struts.action.Action;
>   import org.apache.struts.action.ActionForm;
>   import org.apache.struts.action.ActionForward;
>   import org.apache.struts.action.ActionMapping;
> 
>   public class GetImageAction extends Action {
>   public ActionForward execute(
>   ActionMapping mapping,
>   ActionForm form,
>   HttpServletRequest request,
>   HttpServletResponse response) throws Exception{
> 
>   byte[] b;
> 
>   //Here the code to take the image from the database (you
>   need the parameter ID).
>   //Put the bytes into array b[]
> 
>   //response.setContentType("image/gif"); //it's not
>   necessary
>   ServletOutputStream sout = response.getOutputStream();
> 
>   sout.write(b);
>   sout.flush(); 
>   sout.close();
> 
>   return null;
>   }
>   }
> 
>   David
> 
> 
> 
>   -Mensaje original-
>   De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>   Enviado el: martes, 25 de julio de 2006 14:34
>   Para: user@struts.apache.org
>   Asunto: Displaying images from database.
> 
> 
>   Hi All,
> 
> 
> 
> 
>   My application saves the images in database as BLOB. I now want to
>   display these images stored in my database. How can I do this in struts
>   2.0 ?
> 
> 
> 
> 
>   Thanks & Regards
> 
>   Prerna
> 
> 
> 
> 
>   The information contained in this electronic message and any attachments
>   to this message are intended for the exclusive use of the addressee(s)
>   a

Re: Displaying images from database.

2006-07-25 Thread Thomas Joseph
Hi Prerna,

Use the Action Class for the image display solely for image display. When the 
browser executes the   tag, it is 
basically giving a saparate request to your action class that generates the 
image.  Notice that the action class returns null, which means that the action 
class will render the response itself and will not forward to any JSP page.  
The remaining protions of your JSP will be generated by other Action Class 
forwards as usual.

Hope this helps to understand better.

Thanks and Regards,
Thomas Joseph 

Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin-682015 | India 
www.kottsoftware.com 

This email (including any attachments) is subject to copyright, the information 
in it is confidential, and it is legally privileged. Use of this email or of 
any information in it other than by the addressee is unauthorized and unlawful. 
If you are not the intended recipient of the mail, kindly intimate the author 
of the mail and delete the same. 


  - Original Message - 
  From: [EMAIL PROTECTED] 
  To: user@struts.apache.org 
  Sent: Tuesday, July 25, 2006 6:37 PM
  Subject: RE: Displaying images from database.



  Hi David

  Thanks for a prompt response.

  But I also want to display other things on the jsp page besides the
  image.
  For e.g.

  My jsp page would have

  Company name, Address, Business Area and its logo with an EDIT button
  and when the user clicks on the EDIT button he can update Address
  information and save the changes made

  How can I achieve this?

  Thanks & Regards
  Prerna

  -Original Message-
  From: David Soler [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, July 25, 2006 6:43 PM
  To: Struts Users Mailing List
  Subject: RE: Displaying images from database.

  Try the following:

  /*** JSP file /

  <%@ taglib uri="/tags/struts-html" prefix="html" %>
  
  
  
  
  
  <%
  HashMap params = new HashMap();
  params.put("ID", request.getParameter("ID"));
  pageContext.setAttribute("params", params);
  %>
  
  
  


  /*** Action class */

  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import javax.servlet.*;
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;

  public class GetImageAction extends Action {
  public ActionForward execute(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) throws Exception{

  byte[] b;

  //Here the code to take the image from the database (you
  need the parameter ID).
  //Put the bytes into array b[]

  //response.setContentType("image/gif"); //it's not
  necessary
  ServletOutputStream sout = response.getOutputStream();

  sout.write(b);
  sout.flush(); 
  sout.close();

  return null;
  }
  }

  David



  -Mensaje original-
  De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Enviado el: martes, 25 de julio de 2006 14:34
  Para: user@struts.apache.org
  Asunto: Displaying images from database.


  Hi All,




  My application saves the images in database as BLOB. I now want to
  display these images stored in my database. How can I do this in struts
  2.0 ?




  Thanks & Regards

  Prerna




  The information contained in this electronic message and any attachments
  to this message are intended for the exclusive use of the addressee(s)
  and may contain proprietary, confidential or privileged information. If
  you are not the intended recipient, you should not disseminate,
  distribute or copy this e-mail. Please notify the sender immediately and
  destroy all copies of this message and any attachments.


  WARNING: Computer viruses can be transmitted via email. The recipient
  should check this email and any attachments for the presence of viruses.
  The company accepts no liability for any damage caused by any virus
  transmitted by this email.


  www.wipro.com

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



  The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

  WARNING: Computer viruses can be transmitted via email. The recipient should 
check this ema

Re: Displaying images from database.

2006-07-25 Thread vijay venkataraman
Say if all request for images will refer to the same action like 
image.do, then

So map this to a particular action.
Set the content type and write the image content to the ServletOutputStream
return null for ActionForward.

The snippet below should give you an idea.
Consider if resource.getResource() returns a byte[]  - (Some how you 
should be able to get a byte[] for the image stored in DB.)
If image is of type gif or jpg/jpeg - then you can do something like 
what is shown below.
  
   String imgType = gif or jpg/jpeg // for understanding.

   String contentType = "image/";
   if(imgType.equalsIgnoreCase("gif")){
   contentType+="gif";
   }else if(imgType.equalsIgnoreCase("jpg")){
   contentType+="jpeg";
   }else {
   contentType = "text/html";
   }
   response.setContentType(contentType);
   ServletOutputStream outStream = response.getOutputStream();
   outStream.write(resources.getResource());
   outStream.flush();
   return null;

Thanks,
Vijay Venkataraman

[EMAIL PROTECTED] wrote:


Hi All,




My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?




Thanks & Regards

Prerna




The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.


WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.


www.wipro.com
 




--DISCLAIMER--
This message is for the named person's use only. It may contain 
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission. 

If you receive this message in error, please immediately delete it and 
all copies of it from your system, destroy any hard copies of it and 
notify the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the 
intended recipient. 

Lisle Technology Partners Pvt. Ltd. and any of its subsidiaries each 
reserve the right to monitor all e-mail communications through its 
networks. 

Any views expressed in this message are those of the 
individual sender, except where the message states otherwise and the 
sender is authorized to state them to be the views of any such entity.


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



RE: Displaying images from database.

2006-07-25 Thread prerna.sawhney

Hi David

Thanks for a prompt response.

But I also want to display other things on the jsp page besides the
image.
For e.g.

My jsp page would have

Company name, Address, Business Area and its logo with an EDIT button
and when the user clicks on the EDIT button he can update Address
information and save the changes made

How can I achieve this?

Thanks & Regards
Prerna

-Original Message-
From: David Soler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 25, 2006 6:43 PM
To: Struts Users Mailing List
Subject: RE: Displaying images from database.

Try the following:

/*** JSP file /

<%@ taglib uri="/tags/struts-html" prefix="html" %>





<%
HashMap params = new HashMap();
params.put("ID", request.getParameter("ID"));
pageContext.setAttribute("params", params);
%>





/*** Action class */

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class GetImageAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{

byte[] b;

//Here the code to take the image from the database (you
need the parameter ID).
//Put the bytes into array b[]

//response.setContentType("image/gif"); //it's not
necessary
ServletOutputStream sout = response.getOutputStream();

sout.write(b);
sout.flush();   
sout.close();

return null;
}
}

David



-Mensaje original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Enviado el: martes, 25 de julio de 2006 14:34
Para: user@struts.apache.org
Asunto: Displaying images from database.


Hi All,




My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?




Thanks & Regards

Prerna




The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments.


WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.


www.wipro.com

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



The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

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



Displaying images from database.

2006-07-25 Thread prerna.sawhney

Hi All,

My application saves the images in database as BLOB.
I now want to display these images stored in my database. How can I do
this in struts 2.0/1.2.8 ?

Thanks & Regards

Prerna

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 25, 2006 6:04 PM
To: user@struts.apache.org
Subject: Displaying images from database.


Hi All,




My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?




Thanks & Regards

Prerna




The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments.


WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.


www.wipro.com


The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

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



RE: Displaying images from database.

2006-07-25 Thread David Soler
Try the following:

/*** JSP file /

<%@ taglib uri="/tags/struts-html" prefix="html" %>





<%
HashMap params = new HashMap();
params.put("ID", request.getParameter("ID"));
pageContext.setAttribute("params", params);
%>





/*** Action class */

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class GetImageAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{

byte[] b;

//Here the code to take the image from the database (you
need the parameter ID).
//Put the bytes into array b[]
 
//response.setContentType("image/gif"); //it's not
necessary
ServletOutputStream sout = response.getOutputStream();

sout.write(b);
sout.flush();   
sout.close();

return null;
}
}

David



-Mensaje original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Enviado el: martes, 25 de julio de 2006 14:34
Para: user@struts.apache.org
Asunto: Displaying images from database.


Hi All,




My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?




Thanks & Regards

Prerna




The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments.


WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.


www.wipro.com

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



Displaying images from database.

2006-07-25 Thread prerna.sawhney

Hi All,



My application saves the images in database as BLOB. I now want to
display these images stored in my database. How can I do this in struts
2.0 ?



Thanks & Regards

Prerna




The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

Re: Displaying Images from database using Struts tags

2006-01-24 Thread Dave Newton
Gary Feidt wrote:
> Your example is using Struts 1.2.6.  Maybe I can upgrade, but I don't
> think so right now.  I guess I was thinking of it in the wrong way as
> you stated, but I sure did not think it would be difficult to display an
> image stored in a database on a web page.
>   
It's not. It doesn't get much easier than us pointing you at the source
code.

There have been several threads regarding this topic, some recently. All
you need to do is write a servlet (my personal preference) or Action
that returns the image data and reference it using a plain HTML IMG tag
(or a Struts img tag if you need to).

http://www.informit.com/guides/content.asp?g=java&seqNum=166&rl=1


Pay particular attention to the HttpServlet implementation with regards
to setting the content type etc.

Dave



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



Re: Displaying Images from database using Struts tags

2006-01-24 Thread Frank W. Zammetti
You don't really need to upgrade to 1.2.6, all you need to do is take the
DownloadAction class (and the ResourceStreamInfo class IIRC) from 1.2.6
and use it.  There's nothing that I recall that would make it not work in
previos versions of Struts.

I have an app that downloads images from a database, and while I wrote a
separate servlet to do it because of some security setup I had to provide
for, the code is extremely similar to the DownloadAction... what your
trying to do is in no way unusual, and anyone that has done it will have
similar-looking code :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]

On Tue, January 24, 2006 10:31 am, Gary Feidt said:
> Your example is using Struts 1.2.6.  Maybe I can upgrade, but I don't
> think so right now.  I guess I was thinking of it in the wrong way as
> you stated, but I sure did not think it would be difficult to display an
> image stored in a database on a web page.
>
> If anyone else has a work around that they are using in Struts 1.2.4 I
> would apprehiate the help.  I do have a DAO layer that is getting my
> data from the database, Actions and Forms to load this into.
>
> Thanks,
>
> Gary
>
 [EMAIL PROTECTED] 1/24/2006 9:07:35 AM >>>
> I think you're thinking about this the wrong way round. Tags run on
> the server to generate HTML content - so all the  tag does
> is render the html markup of  - its then the browsers
> job to download the image referenced in the "src" attribute.
>
> So what you need is to specify a url in that src attribute which will
> run something on the server to get your image from the database and
> return the image's content as the response. You can do that with a
> Struts action - retrieve the image, write it out as the response and
> return "null" (rather than an action forward) - setting the
> appropriate content stuff.
>
> There is a "download action" which is designed to make this kind of
> thing easier (Ithink it was introduced in Struts 1.2.4), details here:
>
> http://wiki.apache.org/struts/StrutsFileDownload
>
> Niall
>
> On 1/24/06, Gary Feidt <[EMAIL PROTECTED]> wrote:
>> Hi Everybody,
>>
>> I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just
> using
>> Struts framework and tags.
>>
>> I am exploring the ability to display images from database - never
> done
>> this before.  I'm guessing I can get the data out by using the
>> java.sql.getBinaryStream
>>
>> Will the  tag display a java.io.InputStream, or is there a
>> better way?
>>
>> Thanks,
>>
>> Gary
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> __
>
> Confidentiality Statement:
> This email/fax, including attachments, may include confidential and/or
> proprietary information and may be used only by the person or entity to
> which it is addressed. If the reader of this email/fax is not the intended
> recipient or his or her agent, the reader is hereby notified that any
> dissemination, distribution or copying of this email/fax is prohibited. If
> you have received this email/fax in error, please notify the sender by
> replying to this message and deleting this email or destroying this
> facsimile immediately.
>
> -
> 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: Displaying Images from database using Struts tags

2006-01-24 Thread Braun, James F
At the risk of getting murdered again for too many comments I'll offer
this recipe

J.

How to read an image from a db and display in an html page

Goal: Display an image that is stored in a database blob in a .jsp page

Synopsis: The blob is read into a byte array that is stored in the
ActionForm. The .jsp page uses a http://struts.apache.org/userGuide/struts-html.html#img

The code:

This reads the image in from the db

// rs is the ResultSet that is returned from the db query

try
{
  pictureStream = rs.getBinaryStream("picture");
  byte[] bytes = new byte[1024*1024]; // some maximum size

  int byteSize = pictureStream.read(bytes); // read in the bytes
  
  byte[] bytesX = new byte[byteSize]; // create a new array of
the proper size
  
  for(int i=0;i
  


  
  

 

-Original Message-
From: Gary Feidt [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 24, 2006 9:53 AM
To: user@struts.apache.org
Subject: Displaying Images from database using Struts tags

Hi Everybody,

I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just using
Struts framework and tags.

I am exploring the ability to display images from database - never done
this before.  I'm guessing I can get the data out by using the
java.sql.getBinaryStream

Will the  tag display a java.io.InputStream, or is there a
better way?

Thanks,

Gary
__

Confidentiality Statement:
This email/fax, including attachments, may include confidential and/or
proprietary information and may be used only by the person or entity to
which it is addressed. If the reader of this email/fax is not the
intended recipient or his or her agent, the reader is hereby notified
that any dissemination, distribution or copying of this email/fax is
prohibited. If you have received this email/fax in error, please notify
the sender by replying to this message and deleting this email or
destroying this facsimile immediately.

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


-- 
This transmission is intended only for use by the addressee(s) named herein and 
may contain information that is proprietary, confidential and/or legally 
privileged. If you are not the intended recipient, you are hereby notified that 
any disclosure, copying, distribution, or use of the information contained 
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received 
this transmission in error, please immediately contact the sender and destroy 
the material in its entirety, whether in electronic or hard copy format. Thank 
you.



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



Re: Displaying Images from database using Struts tags

2006-01-24 Thread Gary Feidt
Your example is using Struts 1.2.6.  Maybe I can upgrade, but I don't
think so right now.  I guess I was thinking of it in the wrong way as
you stated, but I sure did not think it would be difficult to display an
image stored in a database on a web page.

If anyone else has a work around that they are using in Struts 1.2.4 I
would apprehiate the help.  I do have a DAO layer that is getting my
data from the database, Actions and Forms to load this into.

Thanks,

Gary

>>> [EMAIL PROTECTED] 1/24/2006 9:07:35 AM >>>
I think you're thinking about this the wrong way round. Tags run on
the server to generate HTML content - so all the  tag does
is render the html markup of  - its then the browsers
job to download the image referenced in the "src" attribute.

So what you need is to specify a url in that src attribute which will
run something on the server to get your image from the database and
return the image's content as the response. You can do that with a
Struts action - retrieve the image, write it out as the response and
return "null" (rather than an action forward) - setting the
appropriate content stuff.

There is a "download action" which is designed to make this kind of
thing easier (Ithink it was introduced in Struts 1.2.4), details here:

http://wiki.apache.org/struts/StrutsFileDownload 

Niall

On 1/24/06, Gary Feidt <[EMAIL PROTECTED]> wrote:
> Hi Everybody,
>
> I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just
using
> Struts framework and tags.
>
> I am exploring the ability to display images from database - never
done
> this before.  I'm guessing I can get the data out by using the
> java.sql.getBinaryStream
>
> Will the  tag display a java.io.InputStream, or is there a
> better way?
>
> Thanks,
>
> Gary

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

Confidentiality Statement:
This email/fax, including attachments, may include confidential and/or 
proprietary information and may be used only by the person or entity to which 
it is addressed. If the reader of this email/fax is not the intended recipient 
or his or her agent, the reader is hereby notified that any dissemination, 
distribution or copying of this email/fax is prohibited. If you have received 
this email/fax in error, please notify the sender by replying to this message 
and deleting this email or destroying this facsimile immediately.

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



Re: Displaying Images from database using Struts tags

2006-01-24 Thread Dave Newton
Gary Feidt wrote:
> Will the  tag display a java.io.InputStream, or is there a
> better way?
>   
Not that I know of, unless the tag API doc at
http://struts.apache.org/struts-doc-1.2.x/userGuide/struts-html.html#img
is wrong.

You can, however, use an action or a servlet to deliver the image data.

Dave



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



Re: Displaying Images from database using Struts tags

2006-01-24 Thread Niall Pemberton
I think you're thinking about this the wrong way round. Tags run on
the server to generate HTML content - so all the  tag does
is render the html markup of  - its then the browsers
job to download the image referenced in the "src" attribute.

So what you need is to specify a url in that src attribute which will
run something on the server to get your image from the database and
return the image's content as the response. You can do that with a
Struts action - retrieve the image, write it out as the response and
return "null" (rather than an action forward) - setting the
appropriate content stuff.

There is a "download action" which is designed to make this kind of
thing easier (Ithink it was introduced in Struts 1.2.4), details here:

http://wiki.apache.org/struts/StrutsFileDownload

Niall

On 1/24/06, Gary Feidt <[EMAIL PROTECTED]> wrote:
> Hi Everybody,
>
> I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just using
> Struts framework and tags.
>
> I am exploring the ability to display images from database - never done
> this before.  I'm guessing I can get the data out by using the
> java.sql.getBinaryStream
>
> Will the  tag display a java.io.InputStream, or is there a
> better way?
>
> Thanks,
>
> Gary

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



Re: Displaying Images from database using Struts tags

2006-01-24 Thread Hubert Rabago
You'd have to write an Action which reads the image from the DB and
writes it onto the servlet's output stream.  There was a thread just
yesterday which discussed how to do this.  You can set your image URL
to that action and provide it with enough parameters to find your
image in the DB.

Hubert

On 1/24/06, Gary Feidt <[EMAIL PROTECTED]> wrote:
> Hi Everybody,
>
> I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just using
> Struts framework and tags.
>
> I am exploring the ability to display images from database - never done
> this before.  I'm guessing I can get the data out by using the
> java.sql.getBinaryStream
>
> Will the  tag display a java.io.InputStream, or is there a
> better way?
>
> Thanks,
>
> Gary
> __
>
> Confidentiality Statement:
> This email/fax, including attachments, may include confidential and/or 
> proprietary information and may be used only by the person or entity to which 
> it is addressed. If the reader of this email/fax is not the intended 
> recipient or his or her agent, the reader is hereby notified that any 
> dissemination, distribution or copying of this email/fax is prohibited. If 
> you have received this email/fax in error, please notify the sender by 
> replying to this message and deleting this email or destroying this facsimile 
> immediately.
>
> -
> 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]



Displaying Images from database using Struts tags

2006-01-24 Thread Gary Feidt
Hi Everybody,

I'm using Struts 1.2.4, with no frills (JSTL, Struts EL) - just using
Struts framework and tags.

I am exploring the ability to display images from database - never done
this before.  I'm guessing I can get the data out by using the
java.sql.getBinaryStream

Will the  tag display a java.io.InputStream, or is there a
better way?

Thanks,

Gary
__

Confidentiality Statement:
This email/fax, including attachments, may include confidential and/or 
proprietary information and may be used only by the person or entity to which 
it is addressed. If the reader of this email/fax is not the intended recipient 
or his or her agent, the reader is hereby notified that any dissemination, 
distribution or copying of this email/fax is prohibited. If you have received 
this email/fax in error, please notify the sender by replying to this message 
and deleting this email or destroying this facsimile immediately.

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