David, the images are loaded at application start time with the following
method:
/**
* <p>This method returns a {@link java.util.Collection} of all of the
items
* in the data source. This is really the store's catalog.
*
* @param connection The {@link java.sql.Connection} object used to
execute
* the select statement that will retrieve the items.
*
* @return a {@link java.util.Collection} of all of the items in the
data source.
*
* @throws java.sql.SQLException if there is an error selecting the
items.
*/
public static Collection getAllItems(Connection connection) throws
SQLException
{
Collection col = new ArrayList();
String strSQL = "SELECT * FROM Item";
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(strSQL);
while (rs.next())
{
col.add(new ItemBean(rs));
}
return col;
}
The ArrayList col is then made available to the JSP below with the
<jsp:useBean id="catalog".... tag. The item.getImage() method is here:
/**
* <p>This method returns the name of the item's image.
* @return the name of the item's image.
*/
public String getImage()
{return get("IMAGE").toString();}
and the get() method of the subclass is also simple:
/**
* <p>This method retreives a name/value pair from the {@link
DBBeanBase}.
* It is overridden to allow for case in-sensitive retrieval.
*
* @param key the key used to locate the uniquely associated object.
* @return the object uniquely associated with the specified key.
*/
public Object get(Object key)
{
return m_internalMap.get(key.toString().toUpperCase());
}
so, the JSP gets a String from getImage(). The string is the URL for the
<img> tag. Is this what you were looking for?
-Robert
> <%response.setHeader("Cache-Control","no-cache");%>
>
> <!--
> Catalog.htm
> -->
>
> <html>
>
> <head>
> <title>International Beetle Merchants</title>
> </head>
>
> <body bgcolor='white' TEXT='darkblue'>
> <jsp:useBean id="catalog" class="java.util.Collection"
> scope="application"/>
>
> <!-- The main table that defines the header, navbar, and main body-->
> <table width='100%' height='100%' cellpadding='10' cellspacing='0'>
>
> <jsp:include page="header.jsp" flush="true" />
>
> <tr bgcolor='gainsboro'>
>
> <jsp:include page="navbar.jsp" flush="true" />
>
>
> <!-- The main body -->
> <td bgcolor='beige' valign='top'>
> <%
> java.text.NumberFormat nf =
> java.text.NumberFormat.getCurrencyInstance(java.util.Locale.US);
> %>
> <table align='center' border='0' cellspacing='10'>
> <caption><font size='+2'>Catalog</font></caption>
>
> <tr>
> <th>Item #</th>
> <th></th>
> <th>Description</th>
> <th>Price</th>
> <th>Add To Cart!</th>
> </tr>
> <%
> java.util.Iterator i = catalog.iterator();
> while (i.hasNext())
> {
> ItemBean item = (ItemBean)i.next();
> %>
> <tr>
> <td><%=item.getItemId()%></td>
> <td><img src='img/<%=item.getImage()%>' width=100
> height=75></img></td>
> <td><%=item.getDescription()%></td>
> <td><%=nf.format(item.getPrice())%></td>
> <td align='center'>
> <a href='AddToCartEventHandler.do?itemid=<%=item.getItemId()%>'
> title='AddToCartEventHandler.do?itemid=<%=item.getItemId()%>'>
> <img border='0' title='Add To Cart' src='img/addToCart.gif'>
> </img></a></td>
> <%
> }
> %>
> <!-- ------------- -->
>
> </tr>
>
> </table>
>
> </body>
>
> </html>
>
> -----Original Message-----
> From: David Hamilton [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 22, 2002 10:47 PM
> To: [EMAIL PROTECTED]
> Subject: Re: java.lan.OutOfMemoryError
>
>
> Robert,
>
> Thinking about your error, it seems apparent that the socket is being
closed
> before you have finished sending the image.
>
> I don't think you posted the code of your image handing servlet, or did I
> miss it?
>
> david
>
>
>
> ----- Original Message -----
> From: "Robert Douglass" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Friday, March 22, 2002 9:19 PM
> Subject: RE: java.lan.OutOfMemoryError
>
>
> > I changed the JDK back to 1.3.1 (which is what my class files were
> compiled
> > with) and the error message:
> > 2002-03-22 22:17:32 - Ctx( /RobertDouglass ): IOException in: R( /Robert
> > + /img/Beetle4.gif + null) Connection aborted by peer: socket write err
> >
> > is still there every time it loads an image, but I cannot get the
> > java.lang.OutOfMemoryError.
> >
> > Whether this is because more resources are available on my system, I
don't
> > know.
> >
> > -----Original Message-----
> > From: David Hamilton [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, March 22, 2002 9:17 PM
> > To: Tomcat Users List
> > Subject: Re: java.lan.OutOfMemoryError
> >
> >
> > I know that IllegalStateException with TC 4.0x was reported on this list
a
> > few weeks ago - but IIRC the evaluation of it indicated that it was due
to
> > another reason than the one I described below (was it servlet
forwarding,
> or
> > something like that?)
> >
> > Is your similar problem occurring recursively, or just the once?
> >
> > david
> >
> > ----- Original Message -----
> > From: "David Hamilton" <[EMAIL PROTECTED]>
> > To: "Tomcat Users List" <[EMAIL PROTECTED]>
> > Sent: Friday, March 22, 2002 7:55 PM
> > Subject: Re: java.lan.OutOfMemoryError
> >
> >
> > > You sure?
> > >
> > > I only ask because if you are I have to got back to my team member who
> > > reported 4.01 fixed it and
> > > get him to
> > > a) double check with 4.01 and
> > > b) find if 4.03 is different.
> > >
> > > david
> > >
> > > ----- Original Message -----
> > > From: "Vincent Lambert" <[EMAIL PROTECTED]>
> > > To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
> > > Sent: Friday, March 22, 2002 6:09 PM
> > > Subject: RE : java.lan.OutOfMemoryError
> > >
> > >
> > > I encounter similar problem and i am running TC4.0.3 with JDK 1.4.
> > >
> > > -----Message d'origine-----
> > > De : David Hamilton [mailto:[EMAIL PROTECTED]]
> > > Envoy� : vendredi 22 mars 2002 18:59
> > > � : Tomcat Users List; [EMAIL PROTECTED]
> > > Objet : Re: java.lan.OutOfMemoryError
> > >
> > >
> > > > 'java.lan.OutOfMemoryError'
> > >
> > > Coo - is your whole LAN out of memory? Wow! (Sorry couldn't resist.)
> > >
> > > Seriously: You using JDK 1.4? We found that TC 3.2.3 with JDK 1.4
was
> > > giving us a recursive IllegalStateException which locked up the server
> > > and eventually fell over.
> > >
> > > Reason: Any cancelled or closed HTTP request would apparently cause
> > > this problem. Seems that this causes the output stream to be closed
and
> > > under JDK 1.4 any attempt to write to it causes an
> > > IllegalStateException.
> > >
> > > Closer investigation showed that the error handling in 3.2.3 was
fairly
> > > junky, (lots of empty exception handlers, hopefully addressed in
3.3/4.0
> > > series) and it tries to handle by passing it to the error servlet,
which
> > > tries to write out the error, which gives an IllegalStateException,
> > > which redirects to the error servlet, etc.
> > >
> > > Solution: TC 4.01 does not exhibit this behaviour, so we upgraded.
> > >
> > > Hope that helps
> > > david
> > >
> > >
> > > ----- Original Message -----
> > > From: "Robert Douglass" <[EMAIL PROTECTED]>
> > > To: "Tomcat Users List" <[EMAIL PROTECTED]>
> > > Sent: Friday, March 22, 2002 12:06 PM
> > > Subject: RE: java.lan.OutOfMemoryError
> > >
> > >
> > > > I'm using Tomcat 3.2.3, by the way.
> > > >
> > > > -----Original Message-----
> > > > From: Robert Douglass [mailto:[EMAIL PROTECTED]]
> > > > Sent: Friday, March 22, 2002 1:01 PM
> > > > To: Tomcat Users List
> > > > Subject: RE: java.lan.OutOfMemoryError
> > > >
> > > >
> > > > I also get this error:
> > > >
> > > > 2002-03-22 12:59:29 - Ctx( /RobertDouglass ): IllegalStateException
> > > > in: R( /Robe rtDouglass + /img/Beetle5.jpg + null) Current state =
> > > > FLUSHED, new state = CODIN
> > > > G
> > > >
> > > > but once again, only when I try to access it from the link on my
> > > > webpage, not when I run localhost:8080 -----Original Message-----
> > > > From: Robert Douglass [mailto:[EMAIL PROTECTED]]
> > > > Sent: Friday, March 22, 2002 12:53 PM
> > > > To: Tomcat Group
> > > > Subject: java.lan.OutOfMemoryError
> > > >
> > > >
> > > > Hi all,
> > > > When I run my webapp from localhost, everything seems to be fine.
When
> > >
> > > > I
> > > put
> > > > a link to in on my website and try running accessing it from there,
I
> > > > get: 2002-03-22 12:47:12 - Ctx( /RobertDouglass ): Exception in:
> > >
> > > > /RobertDouglass + /img/Beetle8.jpg + null) -
> > > > java.lang.OutOfMemoryError and Tomcat eventually crashes, but not
> > > > before my data is corrupted.
> > > >
> > > > I also get the following error:
> > > > 2002-03-20 22:27:01 - Ctx( /RobertDouglass ): IOException in:
> > >
> > > > /RobertDouglass
> > > > + /img/Beetle6.jpg + null) Software caused connection abort: socket
> > > > + write
> > > > error
> > > >
> > > > where do I start looking to fix this?
> > > >
> > > > Thanks,
> > > > Robert Douglass
> > > >
> > > >
> > > > --
> > > > To unsubscribe:
<mailto:[EMAIL PROTECTED]>
> > > > For additional commands:
<mailto:[EMAIL PROTECTED]>
> > > > Troubles with the list:
<mailto:[EMAIL PROTECTED]>
> > > >
> > > >
> > > > --
> > > > To unsubscribe:
<mailto:[EMAIL PROTECTED]>
> > > > For additional commands:
<mailto:[EMAIL PROTECTED]>
> > > > Troubles with the list:
<mailto:[EMAIL PROTECTED]>
> > > >
> > > >
> > > > --
> > > > To unsubscribe:
<mailto:[EMAIL PROTECTED]>
> > > > For additional commands:
<mailto:[EMAIL PROTECTED]>
> > > > Troubles with the list:
<mailto:[EMAIL PROTECTED]>
> > > >
> > > >
> > >
> > >
> > > --
> > > To unsubscribe: <mailto:[EMAIL PROTECTED]>
> > > For additional commands: <mailto:[EMAIL PROTECTED]>
> > > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> > >
> > >
> > > --
> > > To unsubscribe: <mailto:[EMAIL PROTECTED]>
> > > For additional commands: <mailto:[EMAIL PROTECTED]>
> > > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe: <mailto:[EMAIL PROTECTED]>
> > > For additional commands: <mailto:[EMAIL PROTECTED]>
> > > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe: <mailto:[EMAIL PROTECTED]>
> > For additional commands: <mailto:[EMAIL PROTECTED]>
> > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > To unsubscribe: <mailto:[EMAIL PROTECTED]>
> > For additional commands: <mailto:[EMAIL PROTECTED]>
> > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>