On 8/3/05, Givler, Eric <[EMAIL PROTECTED]> wrote: > I'm having a heck of a time trying to get the Bayern example from chapter 11 > working, and I'm really not sure why.... >
It looks like there's a bug in your container. I just tried out your code on Resin 3.0.14, and everything works as expected. -- Martin Cooper > I created an enterNumber.jsp page: > > <%@ page contentType="text/html;charset=windows-1252"%> > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> > <title>untitled</title> > </head> > <body> > <form action="parseNumberCarefully.jsp" method="post"> > Enter your favorite number <input type="text" name="favorite"/> > <br/><input type="submit" name="submit" value="Submit"/> > </form> > </body> > </html> > > > I created an parseNumberCarefully.jsp page: > > <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> > <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%> > > <html> > <head> > <title>parseNumberCarefully.jsp</title> > </head> > <body> > <p>You entered "<c:out value="${param.favorite}"/>"</p> > <c:catch var="parsingError"> > <fmt:parseNumber var="fav" value="${param.favorite}"/> > <p>As far as I can tell, this corresponds to the number > <c:out value="${fav}"/>. > </p> > <p>If you multiply this number by 2 and add 1, you get > <c:out value="${fav * 2 + 1}"/>. I like that number better. > </p> > </c:catch> > <c:if test="${not empty parsingError}"> > Sorry, this doesn’t look like a number to me. Perhaps > you’re in the wrong country? > </c:if> > </body> > </html> > > > If I run the first page, enter a valid#, then click [submit], I get correct > results. > If I run the first page, enter an invalid # (i.e. abcd), then click [submit], > I get correct results. > However, if I enter an invalid#, click [back], then enter a valid number, I > keep getting parse errors. It's as if the <catch> keeps RECREATING the > parsingError exception on subsequent requests even though the data has > changed and is valid. > > The reason I tried to do this simple example was that I was creating a > multi-record entry form, and trying to validate with JSTL. When I did this, > as soon as the form would detect bad data, every record after it would be > considered "invalid data". In these cases, I'd end up either clearing the > rest of the data, or it would retain the first "good data" and ovewrite all > subsequent records, or I'd get a stack trace. I thought all of the code that > I was writing was "syntactically" correct, but it did not produce the results > that I wanted. > > If parseNumberCarefully.jsp has an errorPage attribute defined, and you > remove the <c:catch> tag, and enter an invalid value, an error page is > displayed. Now, if you hit [back] to goto the entry page, and enter a valid > value, it works fine. > > What am I missing? > > I'd appreciate any assistance on this. > > I'm running this against Oc4J (oracle jdeveloper's embedded server) for > Jdeveloper 10g, version 10.1.2, on a Windows 2000 box. > > > --------------------------------------------------------------------- > 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]