Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to pass parameters from a jsf backing bean to a Servlet trhu redirect?

843844Sep 12 2008 — edited Sep 13 2008
Hello you guys.

I have something like this:
Backing Bean:

FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
request.setAttribute("report",obj);
context.getExternalContext().dispatch("/downreport.servlet");

now, How come that on my DownReport Servlet I cannot retrieve the report attribute?
I had to use the dispatch method.
I tried getting a request dispatcher, using include never even called the servlet, using forward got me a response committed error (I know, I could use a response wrapper on a filter, but I want to avoid that).

To solve my problem, I could also do it another way:
Is it possible on a .jsf file, inside f:view and h:form, to post to a normal action (like a servlet url)?
As I understand, the action attribute of a commandButton wors for backing bean methods and face-config outcomes.

So,I tried this:
<h:commandButton value="Botao Teste" action="reportServlet" />

<faces-config>
<navigation-rule>

<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>reportServlet</from-outcome>
<to-view-id>/downreport.servlet</to-view-id>
</navigation-case>

</navigation-rule>
</faces-config>

That didn't work, it tries to direct to downreport.JSP

I am using jsf 1.2 with richfaces.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2008
Added on Sep 12 2008
3 comments
486 views