This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes How to call servlet from JSF ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to call servlet from JSF ?" Watch "How to call servlet from JSF ?" New topic
Author

How to call servlet from JSF ?

Heba Fahmy
Greenhorn

Joined: Feb 03, 2012
Posts: 4
I have a JSF bean , and I want to call a servlet and send to that servlet paramter from the bean , how can I do that ?
any help ??!!
Abhinav Taduka
Greenhorn

Joined: Feb 02, 2012
Posts: 6

You can call servlet from FacesContext. In order to pass parameters to servlet you can use query params. Sample code for that will be as follows.


Heba Fahmy
Greenhorn

Joined: Feb 03, 2012
Posts: 4
The problem that I have a navigation , so when I did this approach I got the following exception
javax.servlet.ServletException: Cannot forward after response has been committed

so how can I provide a navigation role which is important to display the user message that the user's parameters were submitted .
and in the same time I can call the servlet ??

I tried to provide that by the servlet it self , but the response format of the servlet as xml and it must be that because the system logic requires that.

any help ??
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Please don't ask the same question twice.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to call servlet from JSF ?
 
Similar Threads
Where is doGet() in JSF?
Accessing a managed bean directly
How to call servlet from JSF ?
Getting an exception on a dispatch.
[Resolved] Services as Managed Beans