Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can't forward info from servlet to jsp -- HF example p.87  RSS feed

 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



BeerExpert.java:


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)

apache-tomcat-6.0.13


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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets can handle generics.

Depending on which container (and which version) there may be some Java 1.5 features that don't work in JSP.
Which are you using?
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's in my previous post:

$ 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)

apache-tomcat-6.0.13

[ May 29, 2008: Message edited by: sven studde ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Missed that in your previous post.

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!