Re: Making a Database Image Show Up on a Jsp Page
Thank you, Wade and everyone else. ServletOutputStream worked perfectly. Wade Chandler wrote: --- Edmund Urbani [EMAIL PROTECTED] wrote: Philip Cote wrote: I'm trying to write to binary data from a MySQL database into a jpeg file so I can show it on a jsp page but I'm not having much luck. My bean can create files outside the servlet / jsp context using the usual java.io classes. As I understand it, java.io classes aren't allowed for EJBs. Does this apply to plain java beans as well? If so, what are the alternatives for doing what I'm trying to do? your java classes can do anything the VM process is permitted to do, unless you have restricted using a security manager and the catalina.policy file (i think eg. debian tomcat packages do that by default). i'm not sure just jow exactly you are trying to serve those images to the client and why you want to write them (temporarily) to the file system. i would probably want to send them back directly from memory after reading them from the DB as a blob (much like Larry Meadors just suggested while i was writing this ...). Edmund - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] I have never heard that EJB could not use java.io classes. That wouldn't make much sense. Even JDBC some times needs to use streams for it's data. ByteArrayOutputStream and StringWriter are at times needed to perform a task as well for certain things. Sometimes people will make a servlet like this then address this servlet for all images. You'll need to set the content type of your return and stream the bytes out of your DB to the response output in your servlet. Depending on the type of field you have used in the DB you can do something like: java.io.InputStream in = null; try { in = resultSet.getBinaryStream(columnName); java.io.BufferedInputStream bin = new java.io.BufferedInputStream(in); java.io.BufferedOutputStream bout = new java.io. BufferedOutputStream(response.getServletOutputStream()); int iread = bin.read(); while(iread!=-1) { bout.write(iread); iread = bin.read(); } bout.flush(); } finally { if(in!=null) { in.close(); } } Just be sure you have your content type setup and all you need to do there. Then you can simply have a servlet to read images and use as the endpoint in your IMG tags. It's not so bad. Wade - 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: Making a Database Image Show Up on a Jsp Page
Caldarale, Charles R wrote: From: Philip Cote [mailto:[EMAIL PROTECTED] Subject: Re: Making a Database Image Show Up on a Jsp Page My only sticking point is how I'm supposed to write that binary data to the jpeg file. I think the point people are trying to make is that you don't need to write any file at all. The bytes of the image should be output as part of the response stream, using the appropriate MIME type. Or maybe I don't really understand the problem. - Chuck No, it was me who didn't understand the answer. I never thought of servlets being used like that. I've always thought of them as tools that collected data from the appropriate sources and then rendered text and html and that's it. The whole idea of streaming binary data based on a different MIME type than that never occurred to me before. When I finally got it, the solution came together perfectly. It was pretty cool. THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - 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]
Making a Database Image Show Up on a Jsp Page
I'm trying to write to binary data from a MySQL database into a jpeg file so I can show it on a jsp page but I'm not having much luck. My bean can create files outside the servlet / jsp context using the usual java.io classes. As I understand it, java.io classes aren't allowed for EJBs. Does this apply to plain java beans as well? If so, what are the alternatives for doing what I'm trying to do? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Making a Database Image Show Up on a Jsp Page
Edmund Urbani wrote: Philip Cote wrote: I'm trying to write to binary data from a MySQL database into a jpeg file so I can show it on a jsp page but I'm not having much luck. My bean can create files outside the servlet / jsp context using the usual java.io classes. As I understand it, java.io classes aren't allowed for EJBs. Does this apply to plain java beans as well? If so, what are the alternatives for doing what I'm trying to do? your java classes can do anything the VM process is permitted to do, unless you have restricted using a security manager and the catalina.policy file (i think eg. debian tomcat packages do that by default). i'm not sure just jow exactly you are trying to serve those images to the client and why you want to write them (temporarily) to the file system. I'm using Windows XP. I checked the tomcat configuration box. I'm starting Tomcat with the default settings with Tomcat security off. I believe my JVM is also set to default mode though I'm not really sure how to verify this. i would probably want to send them back directly from memory after reading them from the DB as a blob (much like Larry Meadors just suggested while i was writing this ...). I'm really not sure you mean by send them back directly drom memory. Does this have to do with setting the res.setContentType() to image/jpeg rather than text/html. Because if that's the case, then I'm definitely in alien territory. I did try that and it caused firefox to want to download a 0 byte long file. The bright side is Larry is right. Writing the servlet was a breeze as was getting the binary data out of the database. It was easy to have my servlet forward over to the jsp page where the image would actually be displayed. I'm even getting my bean on that page to pull database records. My only sticking point is how I'm supposed to write that binary data to the jpeg file . Is this more an issue of my understanding of the java.io libraries? I thought I understood them but maybe I'm missing the boat on this one. Edmund - 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: tomcat 5.5, jdk1.5 on user mode debian stable hangs after a few days
Good for you! Glad it all worked out. On Mon, 2005-08-08 at 02:25 +0100, Martin Wood wrote: Just to let people know that my application has been running happily for nearly a week now. I actually replaced the JDK1.5 with the blackdown 1.4.2 and installed the compatibility extensions for tomcat. since then its been fine. martin - 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: close pooled conection-by value or by reference
connection.isClosed() should return a boolean telling you whether or not the connection was released. On Sat, 2005-07-23 at 14:18 -0700, Tony Smith wrote: I think this is a classic java question: Pass by reference or by value. I have a DatabaseManager class which takes care of get conection from connection pool and release the connectoin. I am not sure about the release part. Here is my code: class MyMainClass public static final void main(String[] args){ Connection connection = DatabaseManager.getConnection(); //jdbc work. DatabaseManager.closeConnection(connection); ... } public class DatabaseManager { public static Connection getConnection(){ Connection connection = getConectionFromDataSource(); return connection; } public static void closeConnection(Connection conn){ if (conn != null){ try{ conn.close(); }catch(SQLException sqle){ sqle.printStackTrace(); } } conn = null; }} I am not sure if the connection is released Thanks, Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs - 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: Tomcat Architecture
It helps to think of the relationship in a sort of box-inside-a-box relationship. For example, the Server(Tomcat) contains the Service. The Service contains the Engine(eg. Catalina). The Engine contains the hosts (eg www.somedomain.com) Within the different hosts is the Context. Each context is associated with one web application. A web application is made up of any number of servlets, jsp pages, or other resources. The box-inside-a-box analogy breaks down a little with respect to the Connector components. The purpose of Connectors is to provide an way to connect to your web app utilizing different ports (port 80 for regular http access, port 443 for ssl and so forth) Hope this helps. On Fri, 2005-06-24 at 13:41 +0530, niteHawk wrote: Hi Everybody, I was using Tomcat from a long time, but recently started getting more interested in it. Can someone explain me Tomcat Architecture in layman terms / point me to a better website. I didnt understand the documentation at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/architecture/ Thanking You. - 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]
Setting up the Admin Tool
I'm having a hard time getting the admin tool up and running on Tomcat 5.5.7 on Fedora Core Linux. When I try to link to it from the localhost root page, I get a messge telling me I need to install the admin package. Very well. I go off to download the admin tool and use file roller to unzip the thing. Now I have a file jakarta-tomcat-5.5.7-admin.tar-1 sitting in {CATALINA_HOME}/webapps directory. Any ideas? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]