  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | JSP - A mailing list about Java Server Pages specification and reference | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Displaying Generated Image on Jsp | Displaying Generated Image on Jsp 2004-12-18 - By zeeshan haider
Back Hi Govind you can get the context path in Jsp, by calling request.getContextPath() this will return you the path of your application context and so you don't need to hard code any path for example your application context is test/ and you have folder inside it like test/images/hello.gif now you can do this is jsp <img src="<%=request.getContextPath()%>/images/hello.gif>.
the other way is to use ImageIO.
On Fri, 17 Dec 2004 09:13:45 -0500, Frank W. Zammetti <fzlists@(protected)> wrote: > Have a look at the DownloadApp sample I wrote for the new Struts > DownloadAction (http://www.omnytex.com/downloadapp.zip)... You may not > be using Struts, but you should still be able to get the basics of the > approach from that (even NOT using Struts, it should be a trivial matter > to transform the Action class into a Servlet, the rest as I recall > should be independant of Struts). One of the demonstrations is in fact > downloading an image from a database. Incidentally, I'd say this > (getting the image from a database and returning it via a servlet > pointed to by an <img> tag) is the "typical" pattern for solving this > problem. > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > > Jeroen Wenting wrote: > > You can use a Servlet to send the image data as a binary stream to the > > client and in the JSP place an image tag linking to that servlet. > > Data telling the servlet what image data to retrieve can be sent along > > as request parameters or placed in the Http Session. > > > > > > > > -- --Original Message-- -- > > *From:* A mailing list for Java(tm) 2 Platform, Enterprise Edition > > [mailto:J2EE-INTEREST@(protected)]*On Behalf Of *Govind Kotwani > > *Sent:* Friday 17 December 2004 10:52 > > *To:* J2EE-INTEREST@(protected) > > *Subject:* Displaying Generated Image on Jsp > > > > > > Hi, > > > > We have web J2EE web based application which is deployed on weblogic > > 8.1(on Unix) as an ear. > > This EAR contains some EJB's some jar files and a war file. > > > > Now we want to display an image on the jsp after retreiving it from > > the database.Image is stored in the database as a BLOB object. > > Currently what is implemented is e.g as soon as user selects a > > product an image file (.jpg) is generated from the BLOB > > object (at some predefined location say C:\ImageFolder) and in > > jsp(HTML) we display this image with with giving this path in > > IMG src tag. > > > > Is there any way where we can get rid of this absolute path(hard > > coded) path and generate the image at a relative path and display > > from there in our jsp or is there any other wat to achieve it. > > > > =========================================================================== > > To unsubscribe, send email to listserv@(protected) and include in the > > body of the message "signoff J2EE-INTEREST". For general help, send > > email to listserv@(protected) and include in the body of the message > > "help". > > > > =========================================================================== > To unsubscribe, send email to listserv@(protected) and include in the body > of the message "signoff J2EE-INTEREST". For general help, send email to > listserv@(protected) and include in the body of the message "help". >
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|
 |