Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF Seam @RequestParameter File/Image
    text
    copied!<p>i have a Backing Bean in which i read parameter which are not bound to a component. Seam offered that to read get parameter. I used</p> <pre><code>@RequestParameter private String param1; </code></pre> <p>this way he doesn't skip my action method on a validation error, like when i used &lt;param name="param1" value="#{myBean.param1}" /> , because i don't want to render HTML responses but reuse the business logic. Instead i grab the response stream and write the rendered response myself </p> <pre><code>FacesContext ctx = FacesContext.getCurrentInstance(); final HttpServletResponse resp = (HttpServletResponse)ctx.getExternalContext().getResponse(); resp.getOutputStream().write(xml.getBytes()); resp.getOutputStream().flush(); resp.getOutputStream().close(); ctx.responseComplete(); // render response phase done </code></pre> <p>I tried to read the file from the HttpServletRequest inputStream but that was already empty. Is there a way to still get the "file" from JSF. I could use a separate servlet and handle it there, but that would break a little bit how i build the rest of the interface.</p> <p>Thx for any advice.</p> <p>Edit: Just for completeness the code for the input stream</p> <pre><code>final HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest(); ServletInputStream stream = request.getInputStream(); int byt = stream.read(); // byt was -1 </code></pre> <p>Edit Edit: Sorry for the long post. Now i made a separate servlet. There i also get an empty input Stream even though Firefug said i transmitted the file. How can that be empty?</p> <pre><code>@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { boolean isMultipart = ServletFileUpload.isMultipartContent(req); ServletInputStream stream= req.getInputStream(); int test = stream.read(); // test == -1 </code></pre> <p>That servlet code works fine in a separate project, so one of the JSF/Seam servlets in the filter chain has to remove the data. If someone has a hint which one or how to check.</p>
 

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