Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The redirect has failed because you already wrote and committed the response before performing the redirect in the servlet. You seem to think that you can send multiple responses on a single request. This is actually not true. You can send only one HTTP response back per HTTP request, not more. Remove that whole block starting with the <code>FacesUtil#getFacesContext()</code> line. It doesn't belong there.</p> <p>I'm not sure what that servlet is doing, it doesn't seem to do anything useful, but you should instead let the applet itself perform the "redirect" by <code>AppletContext#showDocument()</code> after having called the servlet. You can pass the search criteria (the properties of the Java object instance you're trying to serialize) to the JSF page/bean as GET request parameters the usual way and have JSF to collect it by <code>@ManagedProperty</code> or <code>&lt;f:viewParam&gt;</code> and process it by <code>@PostConstruct</code> or <code>&lt;f:event&gt;</code>.</p> <p>E.g.</p> <pre><code>String query = "?param1=" + URLEncoder.encode(param1, "UTF-8") + "&amp;param2=" + URLEncoder.encode(param2, "UTF-8") + "&amp;param3=" + URLEncoder.encode(param3, "UTF-8"); getAppletContext().showDocument(new URL(getCodeBase(), "MainSearchResult.xhtml" + query), "_SELF"); </code></pre> <p>with <em>either</em></p> <pre><code>@ManagedBean @RequestScoped public class ProductSelection { @ManagedProperty("#{param.param1}") private String param1; @ManagedProperty("#{param.param2}") private String param2; @ManagedProperty("#{param.param3}") private String param3; @PostConstruct public void init() { // Do your business job based on the submitted request parameters. } // ... } </code></pre> <p><em>or</em></p> <pre><code>&lt;f:metadata&gt; &lt;f:viewParam name="param1" value="#{productSelection.param1}" /&gt; &lt;f:viewParam name="param2" value="#{productSelection.param2}" /&gt; &lt;f:viewParam name="param3" value="#{productSelection.param3}" /&gt; &lt;f:event type="preRenderView" listener="#{productSelection.init}" /&gt; &lt;/f:metadata&gt; </code></pre> <p>When implementing it this way, then I think that the clumsy servlet step with all that Java serialization is entirely superfluous. You could just remove it. Also, this way you end up with a nicely bookmarkable, reuseable and searchbot-indexable page which can be opened independently from the applet/servlet.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/4888942/viewparam-vs-managedpropertyvalue-param-id">ViewParam vs @ManagedProperty(value = &quot;#{param.id}&quot;)</a></li> <li><a href="http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ProcessingGETRequestParameters" rel="nofollow noreferrer">Communication in JSF 2.0 - Processing GET request parameters</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload