title: How to show file in GWT client side, instead of Downloading:
body: <p>I need little help to achieve this, in my app user can upload files to server and its stored as blob object, and now i need to show them to user up on there request.</p>
  
  <p>What I am up to is show in below code,</p>
  
  <p>On server side I put content to response:
  (This code is implemented based on this blog post <a href="http://de-water-talks.blogspot.in/2013/03/gwt-file-uploading-and-save-it-to-db.html" rel="nofollow">WaterTalks</a>)</p>
  
  <pre><code>     resp.setContentType("text/plain");
       resp.setHeader("Content-Disposition", "attachment; filename=output.txt");
  
       PrintWriter out = resp.getWriter();
       out.println("This is the output content");
       out.println("Probably something dynamic should go in here:::::");
  
  
  PersistenceManager pm = null;
           try {
                  pm = PMF.get().getPersistenceManager();
                  javax.jdo.Transaction transaction = pm.currentTransaction();
                  Extent e = pm.getExtent(WaterTalkFiles.class, true);
                  Iterator iter = e.iterator();
                  String returns = "";
                  WaterTalkFiles file  =  (WaterTalkFiles)iter.next();
                  Blob blob = file.getData();
                  byte[] buffer = blob.getBytes();
                  String s = new String(buffer);
                  out.println(s);
           } catch (Exception e) {
                  e.printStackTrace();
           } finally {
                  if (null != pm)
                        pm.close();
           }
  </code></pre>
  
  <p>Now in client side when user click show button i want to show the file content in browser, not to download it.</p>
  
  <p>My client side code is:</p>
  
  <pre><code>showfilecontentButton.addClickHandler(new ClickHandler() {
  
              @Override
              public void onClick(ClickEvent event) {
                     String link = "/FileUploadByWaterTalks";
                      container.add(new HTML("&lt;a href=\"" + link + "\"&gt;ShowFile&lt;/a&gt;"));
              }
          });
  </code></pre>
  
  <p>The code above (Client side code) not showing content of file its just downloading the file.
  But I don't want user to download it, I want show them the content of it.</p>
  
  <p>And, do I have to configure something over here to work it out.</p>
  
  <pre><code> resp.setContentType("text/plain");
   resp.setHeader("Content-Disposition", "attachment; filename=output.txt");
  </code></pre>
  
  <p>Hope you got what my problem is. Please be free to share your thoughts and solutions to achieve this. </p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <h2><strong>UPDATED</strong></h2>
  
  <p>Up on the bases of first answer here, I changed some portion of my code:</p>
  
  <p>updated code sections are:</p>
  
  <pre><code>    resp.setHeader("Pragma", "no-cache");
  
  
  
  final String url = "http://127.0.0.1:8888/FileUploadByWaterTalks";
  String name = "output.txt";
  
  Anchor link1 = new Anchor(name);
  RootPanel.get().add(link1);
  link1.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
          Frame f = new Frame(url);
          f.setSize("600px", "400px");
          f.getElement().getStyle().setBorderWidth(0, Unit.PX);
          RootPanel.get().add(f);
        }
      });
  </code></pre>
  
  <p>But still the browser asking me to save the file instead of showing it in the browser itself.</p>