David Newton wrote:Unfortunately, you're also declaring methods in essentially random places.
Bear Bibeault wrote:That is not a standard JSP action. You'll need to let us know what library it is from.
Bear Bibeault wrote:Unless there is a filter to set up the CSClient variable, it will never exist.
Are you sure that you're not supposed to be looking in the session or someplace else for it?
Bear Bibeault wrote:Unless there is a filter to set up the CSClient variable, it will never exist.
Are you sure that you're not supposed to be looking in the session or someplace else for it?
Bear Bibeault wrote:Whoever provided those sample writes extremely sloppy code, in my opinion.
With regards to the scoped variable, if the servlet is the first thing that executes in the request, your fetch will always return null as there is no way that anything will have had an opportunity to set a variable into the request.
Are there filters configured that execute before the servlet?
If your forward is failing -- and again, using an include instead of a forward is sloppy sloppy sloppy -- it's because something is tinkering with the request other than the code you have in the servlet.
Bear Bibeault wrote:
CSClient client = (CSClient)request.getAttribute( "iw.csclient");
The fact that the very first thing you are doing in the servlet is to fetch a request-scoped variable is highly suspicious that something else is executing before the servlet. Otherwise, there would be no opportunity for there to even be such a variable in request scope.
What is it that you're not telling us?
Bear Bibeault wrote:No it doesn't. An include is not a suitable substitute for the forward. The problem lies elsewhere, though I cannot see it upon inspection.
This is a very (and I do mean very) common scenario, so it should all work. There must be more to it than what is posted.
the include() method sends the request to something else (typically another servlet) to do some work and then comes back to the sender!
Bear Bibeault wrote:And, why the init and destroy methods? If you don't have anything to do, omit them.
Bear Bibeault wrote:By the way, why the private method? Why not just have doPost invoke doGet or vice versa?
Craig Treptow wrote:
Found the answer!
Needs to be:
I don't understand why though. Include gives control back to the servlet, but I didn't think I would want for this purpose? At least the Heads First book makes me think I don't want the include.
Craig
Max Rahder wrote:What calls "processRequest()", and does it do anything with the response? My guess is that the calling routine is writing to the response stream.