File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes how to trigger a servlet from JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to trigger a servlet from JSF" Watch "how to trigger a servlet from JSF" New topic

how to trigger a servlet from JSF

lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
i tried to call a servlet but i have the following error:
Cannot forward a response that is already committed

my managed bean code:


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632

My definition of "call" a servlet is when one item of webapp code contacts a server, gets a response, and acts on the response. What you're actually attempting to do is to forward. that is, to, "call" without returning.

JSF is designed to manage requests from end to end, so forwarding is a problem.

However, based on your sample code, I don't know if you really even need JSF for what you're trying to do.

JSF is not a "Master Control Program" that has to be totally in control at all times. It's an assistance framework that acts on individual request/response cycles. If you have a particular client request that doesn't need JSF's forms support, don't try and force it. Instead, write a servlet or JSP and let that servlet/JSP handle the request exactly as you would in a non-JSP app.

Customer surveys are for companies who didn't pay proper attention to begin with.
lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
but from servlet, how do i access my managed bean values?
I agree. Here's the link:
subject: how to trigger a servlet from JSF
Similar Threads
Call to JSF experts
Urgent! Strange problem when calling jasper report in STRUTS
jsf and jasper report (pdf format)
JasperReports in webapp (JSF2)
How to call a servlet from JSF without using dispatch(url)