I got the servlet below to work when the servlet wrote out some html using out.println(). The html displayed correctly in my browser. Then I commented out the out.println() lines, and I tried to attach the info to the request object and then forward the request object to a jsp. However, now I get no output in my browser--just a blank page.
webapps/Beer-v1/result.jsp: I tried various casts on the value returned by request.getAttribute(), but nothing worked.
Hmmm...after some more testing, I think the problem is because I'm using List<String> instead of List. When I use List, my browser displays the output correctly, but I get some "Notes" when I compile the code:
Note: src/com/example/model/BeerExpert.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
Are servlets unable to handle generics?
$ java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-113) Java HotSpot(TM) Client VM (build 1.5.0_06-68, mixed mode, sharing)
Now both versions of my servlet are working. This is the cast that works:
[ May 29, 2008: Message edited by: sven studde ]
[ May 29, 2008: Message edited by: sven studde ] [ May 29, 2008: Message edited by: sven studde ]
I know that Tomcat 5.5 was the first version to ship with the embedded compiler (JDT from the eclipse group) and that the compiler, at that time, was not fully Java 1.5 compliant. This meant that some of the 1.5 features would not work in scriptlet code. I'm not sure about Tomcat 6.