LE Binaries

2003-02-27 Thread Kennedy Clark
I know the answer is probably right in front of my face, but I have not 
been able to locate an explanation for what the LE binaries represent and 
how they are different from the non-LE binaries.  They obviously appear 
to be specific to JDK 1.4, but other than that I'm trying to decide which 
would be better to use.

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


RE: Help Preventing VM Tomcat Crash

2002-02-24 Thread Kennedy Clark

Shawn,
Excellent advice!  The ByteArrayOutputStream worked beautifully.  Thank 
you.  I'm in the process of downloading 1.4 and will see if that works too.
Again, thanks a bunch!
Kennedy

At 03:31 PM 2/23/2002 -0600, Shawn Church wrote:
So much for that theory.

However, your guess is pretty close.  I found something which you might find
interesting.  This is a known bug, which you can check out here:

http://developer.java.sun.com/developer/bugParade/bugs/4502892.html

The problem occurs when the socket is prematurely closed.  The workaround is
to buffer the output via ByteArrayOutputStream, isolating the native method
from stream disconnections.

The evaluation of the bug I will include here for convenience:

snip


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Help Preventing VM Tomcat Crash

2002-02-23 Thread Kennedy Clark

I'm working on a servlet that shrinks JPEG photos on the fly to create 
thumbnails.  When the user selects the thumbnail page, a JSP generates HTML 
that results in many calls to the thumbnail servlet.  If the user is 
patient and waits for all of the thumbnails to load, everything works great 
-- they can click on a thumbnail to see the full-size version of that 
JPEG.  However, if the use clicks on a photo while they are still loading, 
I get the exception dump and crash shown at the bottom.  Any help greatly 
appreciated!  Regards, Kennedy

Here is my thumbnail servlet:
/*
  * Note: JPEG manipulation code comes from Sun:
  * http://developer.java.sun.com/developer/TechTips/1999/tt1021.html#tip1
  */
package gallery.servlet;

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;


/**
  * Return a thumbnail of the image specified in the name parameter
  */

public class Thumbnail extends HttpServlet {


 public void doGet(HttpServletRequest request,
   HttpServletResponse response)
 throws IOException, ServletException
 {
 response.setContentType(image/jpeg);
 File f = new File(request.getParameter(name));
 if (!f.exists())
 return;
 OutputStream os = response.getOutputStream();
 createThumbnail(request.getParameter(name), os, 150);
 }

 /**
  * Reads an image in a file and creates a thumbnail to the output stream
  *
  * @param orig  The name of image file.
  * @param thumb The name of thumbnail file.
  * Will be created if necessary.
  * @param maxDim The width and height of the thumbnail must
  * be maxDim pixels or less.
  */
 public static void createThumbnail(String orig, OutputStream os, int 
maxDim) {
 try {
 // Get the image from a file.
 Image inImage = new ImageIcon(orig).getImage();

 // Determine the scale.
 double scale = (double)maxDim/(double)inImage.getHeight(null);
 if (inImage.getWidth(null)  inImage.getHeight(null)) {
 scale = (double)maxDim/(double)inImage.getWidth(null);
 }

 // Determine size of new image.
 // One of them should equal maxDim.
 int scaledW = (int)(scale*inImage.getWidth(null));
 int scaledH = (int)(scale*inImage.getHeight(null));

 // Create an image buffer in which to paint on.
 BufferedImage outImage =
   new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);

 // Set the scale.
 AffineTransform tx = new AffineTransform();

 // If the image is smaller than
 //the desired image size,
 // don't bother scaling.
 if (scale  1.0d) {
 tx.scale(scale, scale);
 }

 // Paint image.
 Graphics2D g2d = outImage.createGraphics();
 g2d.drawImage(inImage, tx, null);
 g2d.dispose();

 // JPEG-encode the image and write to file.
 //OutputStream os = new FileOutputStream(thumb);
 JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
 encoder.encode(outImage);
 //os.close();
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
}



And here is the exception/crash:
java.io.IOException: reading encoded JPEG Stream
 at sun.awt.image.codec.JPEGImageEncoderImpl.writeJPEGStream(Native 
Method)
 at 
sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:475)

 at 
sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:231)
 at gallery.servlet.Thumbnail.createThumbnail(Thumbnail.java:85)
 at gallery.servlet.Thumbnail.doGet(Thumbnail.java:35)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
 at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
 at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at 

RE: Help Preventing VM Tomcat Crash

2002-02-23 Thread Kennedy Clark

Hi Shawn,

Many thanks for the note  the suggestion!  I am using MySQL as my Db and 
MM.MySQL is my driver (mm.mysql-2.0.11-bin.jar).  Given that this is a Type 
4 driver, I don't think I should be getting a native code crash involving 
database access, right?

I could be missing something, but it seems that the 
sun.awt.image.codec.JPEGImageEncoderImpl.writeJPEGStream() method (which is 
native code) is trying to write to my output stream and running into 
trouble.  I assume this is because the user has clicked on an image serving 
as a link to another web page and now Tomcat is off trying to handle the 
new page.  My best guess is that in the process of doing so, the output 
streams used by writeJPEGStream() are being torn down, but the native code 
doesn't know this and it's causing the VM to puke.  Does anyone think my 
logic makes sense?  Better yet, does anyone know a way to prevent it? :-)

Regards, Kennedy

At 09:02 AM 2/23/2002 -0600, Shawn Church wrote:
Looks like you are using the JDBC-ODBC bridge (maybe to an MS Access or MS
SQL Server database?), which is not thread-safe and is not intended for use
in production environments.  My guess is that one thread (the current thread
servicing the Thumbnail servlet) has a db connection open, and the next
request (the user clicking the thumbnail) opens another db connection.  This
guess is based on these lines in your exception:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : unknown exception code occurred at PC=0x77fb16cc
Function name=RtlTraceDatabaseEnumerate
Library=C:\WINNT\System32\ntdll.dll

If this is the case, try finding a pure Java (type 4) JDBC driver for your
database.

Shawn


-Original Message-
From: Kennedy Clark [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 23, 2002 5:36 AM
To: [EMAIL PROTECTED]
Subject: Help Preventing VM  Tomcat Crash


I'm working on a servlet that shrinks JPEG photos on the fly to create
thumbnails.  When the user selects the thumbnail page, a JSP generates HTML
that results in many calls to the thumbnail servlet.  If the user is
patient and waits for all of the thumbnails to load, everything works great
-- they can click on a thumbnail to see the full-size version of that
JPEG.  However, if the use clicks on a photo while they are still loading,
I get the exception dump and crash shown at the bottom.  Any help greatly
appreciated!  Regards, Kennedy

Here is my thumbnail servlet:
/*
   * Note: JPEG manipulation code comes from Sun:
   * http://developer.java.sun.com/developer/TechTips/1999/tt1021.html#tip1
   */
package gallery.servlet;

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;


/**
   * Return a thumbnail of the image specified in the name parameter
   */

public class Thumbnail extends HttpServlet {


  public void doGet(HttpServletRequest request,
HttpServletResponse response)
  throws IOException, ServletException
  {
  response.setContentType(image/jpeg);
  File f = new File(request.getParameter(name));
  if (!f.exists())
  return;
  OutputStream os = response.getOutputStream();
  createThumbnail(request.getParameter(name), os, 150);
  }

  /**
   * Reads an image in a file and creates a thumbnail to the output
stream
   *
   * @param orig  The name of image file.
   * @param thumb The name of thumbnail file.
   * Will be created if necessary.
   * @param maxDim The width and height of the thumbnail must
   * be maxDim pixels or less.
   */
  public static void createThumbnail(String orig, OutputStream os, int
maxDim) {
  try {
  // Get the image from a file.
  Image inImage = new ImageIcon(orig).getImage();

  // Determine the scale.
  double scale = (double)maxDim/(double)inImage.getHeight(null);
  if (inImage.getWidth(null)  inImage.getHeight(null)) {
  scale = (double)maxDim/(double)inImage.getWidth(null);
  }

  // Determine size of new image.
  // One of them should equal maxDim.
  int scaledW = (int)(scale*inImage.getWidth(null));
  int scaledH = (int)(scale*inImage.getHeight(null));

  // Create an image buffer in which to paint on.
  BufferedImage outImage =
new BufferedImage(scaledW, scaledH,
BufferedImage.TYPE_INT_RGB);

  // Set the scale.
  AffineTransform tx = new AffineTransform();

  // If the image is smaller than

Access web.xml context-param From A Bean?

2002-02-17 Thread Kennedy Clark

I have values I want set at deployment time declared in my web.xml.  I am 
accessing these with no problem from my JSPs with:
%= application.getInitParameter(paramNameHere) %

However, for my business logic which I have pulled out the if JSPs and put 
into beans, I can't figure out how to access these values?  Is there way to 
get to values stored in the container from a bean?

TIA, Kennedy


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Popup Browser Windows Tomcat Realm Authentication

2002-02-14 Thread Kennedy Clark

I'm using Tomcat 4.0.1 to develop a web-site application that needs to use 
popup browser windows.  I have the main page protected by a JDBCRealm and 
it's working nicely.  Now that I've added the popups, the popup window 
opens fine using the authentication of the main windows.  However, when you 
close the popup, you cannot do anything in the main windows without having 
to re-authenticate.  I've tried using both a target= attribute on an a 
href=, as well as a JavaScript onClick=open(... to create the popup 
windows -- the results are the same -- the authentication follows the child 
window and then dies with it.  How can I fix this?  All help greatly 
appreciated!

Thanks,
Kennedy


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]