Right after installing the ‘ora’ example application for Tomcat, I surfed to http://localhost:8080/ora no problem, then clicked on Chapter 5, Current Date/Time example. Long delay, then finally the date and time are displayed. But in my Tomcat startup console window, I see:
2000-12-29 10:18:37 - Ctx( ): IOException in: R( + /tomcat-power.gif + null) socket write error (code=10053) 2000-12-29 10:18:37 - Ctx( ): IOException in: R( + /index.html + null) socket write error (code=10053) Do I have an install problem? |
Answer: First, the delay you see the first time you access a JSP page is the time it takes to convert the JSP page into a servlet class file. It only happens the first time, and when you change the JSP page.The error message means that Tomcat could not send the complete response to the browser, because the browser has already closed its connection.As far as I know, this only happen with Internet Explorer (IE). IE seems to close the connection before it has received the complete response when it asks for a resource it already has in its cache. So the first time you load the Tomcat index page, everything is fine. But from then on, both the index.html and the image file are in IE’s cache, and you see this message. It doesn’t cause any problems though, so you can just ignore it. Rumor has it that this problem can be fixed with the latest patches for IE, at least on some Windows platforms. You can also reduce the log level for the Tomcat server so it doesn’t print these error messages. See the Tomcat configuration documents for details. If you use Netscape instead, you’ll notice that it behaves according to the HTTP spec, so you don’t get this message. |
Monthly Archives: January 2001
Must beans be part of a package to be found?
I have bean class named User. It’s not in a named package so I try to use this bean in a JSP page like this:
<jsp:useBean id="user" class="User" /> This doesn’t work. I get a message about class User not being found. Just to test, I replaced my class name with “java.util.Date”, and then the page was accepted. Do I have to put the class in a package? |
Answer: JDK 1.4 update: In Sun’s JDK 1.4 compiler, you can no longer import any type from the unnamed package into a class in a named package. In other words, your beans really must be part of a package. For details, see Sun’s Bug Parade. The rest of this answer is valid for previous versions of Sun JDKs and possibly for other compilers such as Jikes.The reason the JSP container can not find your bean when it’s not part of a package has to do with how Java in general resolves references to classes references through their short name. I describe this in an article at the O’Reilly site:
There are other tips in this article that you may find useful, so please read it when you get a chance. |
Why are my bean properties not recognized by the JSP container?
I have created a simple bean that looks like this:
package com.mycomp; public class TestBean { private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String v) { firstName = v; } public String getLastName() { return lastName; } public void setLastName(String v) { lastName = v; } } I have compiled it and placed the class file in the WEB-INF/classes/com/mycomp directory for the application, as described in the book. Still, when I use a <jsp:setProperty> or <jsp:getProperty> action and specify the property names Error: 500 Location: /test/jsp/test.jsp Internal Servlet Error: org.apache.jasper.JasperException: Cannot find any information on property 'FirstName' in a bean of type 'com.mycomp.TestBean'. What’s going on here? |
Answer: Java is a case-sensitive language, and all bean property names are required to start with a lowercase letter. So the access methods in your bean: getFirstName()/setFirstName() getLastName()/setLastName() correspond to properties named “firstName” and “lastName”. The property name is the method name minus the get/set prefix, with the first character changed from upper to lower case. That’s why the container can’t find a property named “FirstName”, since it starts with an uppercase “F” instead of a lowercase “f”. This naming rule is followed in all examples in the book, but it’s not explicitely described anywhere. I’ll put it on my list of things to be improved in the next edition of the book. |