Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a servlet from a backing bean

 
Lance Cash
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been poking around all over the place looking for how one can invoke a servlet from within a backing bean and have come up empty. The most promising code I found was:



The problem is...it doesn't work! I don't know if it is an icefaces issue or what, but I get the following error:


java.io.IOException: Cannot dispatch on XMLHTTP request.


I'm hoping someone out there will have other ideas, and please...no suggestions on how to better design this thing. It's gotta stay a servlet! This isn't the only place this thing gets used. I am open, however to other suggestions on how to call the servlet. Originally, it was being invoked via an outputLink, but now it needs to perform some action as well. I realize that I could create a hidden input button and invoke it with some javascript, but that just seems awfully hokie to me. I would like to present my boss with a more elegant solution than that.

Thanks in advance, everyone. Lance.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the role of the Servlet in this case? Does it perform business logic exclusively, or does it generate markup for display?
 
Lance Cash
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is generating a pdf report of system activity.
 
Lance Cash
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, well...I figured out how to call the servlet from the backing bean, but it ended up not helping me out. This particular servlet needs to be invoked from the right context in order to execute properly so that it can grab stuff like the user state from the session. When calling it from a bean as I did, that stuff isn't instantiated. But for anyone that may be interested in how to do this in the future, here you go:



I ended up having to call on javascript to the rescue after all via a hidden button invoked by the onclick() method of the outputLink tag.

Thanks anyways, guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic