1 Reply Latest reply on May 19, 2008 5:46 PM by bard123

    problem with a jsp file

    bard123

      Hi,


      I use the version of 2.0.2.CR1 seam, I would like execute a jsp file, but the problem is that I do not.
      I created a form with a button which allows you to download a file, when you click on the button I open the file to download but the problem is that in the address bar of firefox, it opens one .seam and no .jsp, so how can I force them to open a file .jsp so that it runs.


      Here's what I put in my web.xml:



       <context-param>
              <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
              <param-value>.jsp</param-value>
        </context-param>





      before the place I had made. xhtml but I could not do file jsp


      Here is my form:



      <s:button value="Downloader" view="/download.jsp"></s:button>




      download.jsp :



      <?xml version="1.0"?>
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
      <!-- Download.jsp
           Copyright (c) 2002 by Dr. Herong Yang
      -->
      <jsp:directive.page session="false" import="java.io.*" />
      <jsp:scriptlet>
           String p = request.getParameter("name");
             out.println(p);
            response.setHeader("Content-disposition", 
               "attachment; filename="+p);
            try {
               int l = (int) new File("c:\\yannick\\tutoriaux\\jpa.pdf").length();
               response.setContentLength(l);
               byte[] b = new byte[l];
               FileInputStream f = new FileInputStream("c:\\yannick\\tutoriaux\\jpa.pdf");
               f.read(b);
               ServletOutputStream o = response.getOutputStream();
               o.write(b,0,l);
               o.flush();
               o.close();
               f.close();
            } catch (Exception e) {
              out.println(e);
            }
         
       
       </jsp:scriptlet>
      </jsp:root>




      How do I solve this problem ?


      Thank you

        • 1. Re: problem with a jsp file
          bard123

               
          I changed my file web.xml like this:



           <context-param>
                  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                  <param-value>.xhtml</param-value>
              </context-param>





          So my form is in a file .xhtml :



          <s:button value="Downloader" view="/download.jsp"></s:button>




          I always have my file .jsp but when I go to my file jsp, I see the contents of this file in firefox.


          Where is the problem ?


          Thank you