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 provide navigation rule and call servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how provide navigation rule and call servlet" Watch "how provide navigation rule and call servlet" New topic

how provide navigation rule and call servlet

Heba Fahmy

Joined: Feb 03, 2012
Posts: 4
I have 2 Jsf pages with navigation rule .

and in the bean I call servlet .

The parameters that the user enter are sent to the servlet which makes an xml format response (The system logic requires that ).
and with the navigation rule I can display to the user that his parameter has submitted.

The problem is :-
The navigation rule doesn't work with servlet calling in the bean ,
it throws the following exception
javax.servlet.ServletException: Cannot forward after response has been committed

so how can I display to the user that his parameter has been submitted ?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17257

OK. Let's start by pinning down the terminology. Sometimes there's value in nit-picking.

You never "call" servlets, you make requests to them. Backing up even further, when a web app makes a request of another web app, that's really just a web services request.

You also seem to be saying that you want one user request to generate 2 separate outputs, in 2 different formats (content-types). HTTP doesn't do that. One request, one response. No more, no less. So you can either have the button, the XML or build an HTML page with a button on it that displays the XML as text, but you can't have the XML and the button as 2 separate output streams from the same request.

In any event, you shouldn't generate XML from JSF, just as you shouldn't generate any other non-HTML format data from JSF. I'm ignoring the fact that xhtml is both HTML and XML, since the "html" part is what counts. JSF generates html. To generate non-html XML, use a servlet, instead, just like I advised on a recent thread about generating Excel.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: how provide navigation rule and call servlet
It's not a secret anymore!