aspose file tools*
The moose likes JSF and the fly likes how we forward a JSF page into Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "how we forward a JSF page into Servlet" Watch "how we forward a JSF page into Servlet" New topic
Author

how we forward a JSF page into Servlet

Vimal Bharathi Andiappan
Greenhorn

Joined: Jun 12, 2008
Posts: 7
Hi i am new to JSF , I have a problem how to forward a JSF page into Sevlet. Same thing i will be used in jsp means it is very easy through (form action="") but in JSF there is no "form action ". Any body knows please reply
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

A JSF page can link to any kind of target, including servlets. However a JSF FORM is expected to talk to JSF. That's because you're getting fields populated from JSF and JSF manages a cycle of repeated validations and error displays until the user either gets the data clean enough to use of abandons the page. JSF also carries a lot of freight that other platforms don't want/need/understand.

In order to submit a form to a servlet, it has to be a non-JSF form, so you usually are going to find life simpler if the form page is completely non-JSF - a straight JSP, servlet-generated HTML, Struts, or whatever. Since you normally pre-load data into a form, this usually means that the JSF action processor that takes you there is going to have to do a forwarding operation to invoke the form setup code.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jerwin Louise Uy
Ranch Hand

Joined: Oct 27, 2007
Posts: 75
Client Side

- You can embed the resource (with can either be a servlet or a resource), but you have the pass the parameters in the traditional way.

Server Side

- You can either perform a redirect or a dispatch

## redirect
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext ec = facesContext.getExternalContext();
ec.redirect(url)

## dispatch
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext ec = facesContext.getExternalContext();
ec.dispatch(url)

In essence, ExternalContext object serves as your window to non jsf resources.

I hope this helps.


Uy Jerwin Louise Vergara
Junior Developer / Research and Development at Incuventure Partners Corporation
email: jerwin.uy@incuventure.net
Mahendra Pratap
Ranch Hand

Joined: Feb 25, 2008
Posts: 42

can some body please tell me what to put in url. the actual URL or just the path of class file specifiled in servlet mapping in web.xml

thanks a lot


Mahendra
http://randomtechieblog.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how we forward a JSF page into Servlet
 
Similar Threads
how this happeded? not expected but pleasant!
how can i forward action mapping in struct-config.xml?????????????
JSP Forward
JavaServer Faces - forwarding (like JSP:FORWARD) but ...
In JSF there is no form action