You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrew Leeb <le...@mekons.com> on 2003/04/08 21:25:16 UTC

RE: Marking servlet org.apache.catalina.INVOKER.ImageRender as un available

JS,Srinivasu,

I did figure out what the problem was: the path I was using to reference
the servlet from the JSP page had to be changed to include the root
directory of my webapp. 

the (very simple) web.xml file is

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
        <servlet>
                <servlet-name>ImageRender</servlet-name>
                <servlet-class>ImageRender</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>ImageRender</servlet-name>
                <url-pattern>/ImageRender</url-pattern>
        </servlet-mapping>
</web-app>

I had been referencing it with the path "/servlet/ImageRender". I
changed it to "PhotoGallery/servlet/ImageRender". That made it work.

The code that retrieves binary data from the database is:

try {
            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
            java.sql.Connection conn;
            conn =
DriverManager.getConnection("jdbc:mysql://yourhost/yourdatabase?user=xxx&password=xxxxx");
            Statement stmt = conn.createStatement();
            
            ResultSet rs=stmt.executeQuery("select photo from pics where
your_qualifications = whatever_you_need_to_do);
            if( rs.next() ) {
                InputStream in = rs.getBinaryStream(1);
                response.setContentType("image/jpg");
                ServletOutputStream out = response.getOutputStream();
                int c;
                while((c = in.read()) != -1) {
                    out.write(c);
                }
                in.close();
                out.close();
            }
            
        } catch (Exception e) {
            e.getMessage();
            
        }

This code needs tweaking, but should get you started. Hope this helps.

Thanks,
-andy


On Wed, 2003-04-09 at 15:11, Srinivasu Gandu wrote:
> Would you post code for this ImageRender servlet.. I am in need of
> that..that would be great!
> And also my database access is ok yesterday by servlet and it is not ok with
> the same servlet..?!#%
> 
> -----Original Message-----
> From: JS [mailto:smartt@dcs.kcl.ac.uk]
> Sent: Tuesday, April 08, 2003 2:35 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Marking servlet org.apache.catalina.INVOKER.ImageRender as
> unavailable
> 
> 
> Hi Andrew,
> Sorry to email u directlt on this, but I was wondering if you managed to
> find a solution to your problem. I have just encountered the same thing
> and think it has something to do with errors in my web.xml file.
> Ive just posted a message to tomcat-user and "fingers crossed".
> Would appreciate it if you had any advice.
> 
> Regards & Thanks
> JS
> 
> > Hi all
> >
> > I'm having some difficulty understanding why I'm getting this error in
> > the logs:
> >
> > StandardWrapper[:org.apache.catalina.INVOKER.ImageRender]: Marking
> > servlet org.apache.catalina.INVOKER.ImageRender as unavailable
> > 2003-04-06 16:45:00 invoker: Cannot allocate servlet instance for path
> > /servlet/ImageRender
> > javax.servlet.ServletException: Wrapper cannot find servlet class
> > ImageRender or a class it depends on
> >
> > Problem in brief: Servlet works when called directly i.e. in a URL, but
> > not when called from a JSP page.
> >
> > Overview of the system: a very simple photo album. Images are stored as
> > binary data in a database. A serlvet, ImageRender, gets the binary data
> > from the database. A JSP page calls the servlet, ImageRender, from
> > within an img src tag. If I call the servlet directly, the image
> > displays. However, when I call it from the JSP page, it will not
> > display.
> >
> > Calling ImageRender from the JSP page worked yesterday, then stopped
> > working today.
> >
> > I have searched archives concerning this and not found anything
> > helpful. Any suggestions would be greatly appreciated.
> >
> > Thanks,
> >
> > -andy
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For
> > additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
-- 
Andrew Leeb <le...@mekons.com>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org