How to make file download in JSP ?

Friends,
i am using following code :
// LISTING FILES IN DIR
        out.println("<br>");
        File dir = new File(dirName);
        String[] children = dir.list();
             if (children == null)
        // Either dir does not exist or is not a directory
             else
                %>
                <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="68%" id="AutoNumber1">
                <tr>
                    <td width="50%" align="center"><font face="Verdana">File</font></td>
                    <td width="50%" align="center"><font face="Verdana">Action</font></td>
                      </tr>   
                    <%
                    for (int i=0; i<children.length; i++)
                    // Get filename of file or directory
                    String filename = children;
//out.println(filename);
%>
<tr>
<td width="50%">
<p align="center"><font face="Verdana"><%=filename %></font></td>
<td width="50%">
<p align="center"><font face="Verdana"><a href="<%= children[i %">">View</a></font></td>
</tr>
<%
out.println("<br>");
%>
SInce i am not able to download file from link.
link shows path correct but why its not working ??
HELP ME.
*i don't want to show real path( physical location of file) on file donwload link.*
Example :
*it will not allow to show like following :*
*C:\project\webUpload\build\web\fuploads\file2.jpg*
*it may allow like :*
*\webUpload\fuploads\file2.jpg*
Thanks</a>

My friend you are getting it all wrong here...
Here we would be taking help of a dedicated servlet to locate and download a file(which would be the output the respective concent of depeding of the fineName or fileId you send in).
Please find some time and try to consider the below case...
Say i have a Servlet which takes a Request of detailed filePath and would give output as file itself....
and you prompt you give a link to that servlet from you JSP to download that file...
Checkout the below Code snippets to get some idea
DownloadPrompting.JSP:
==================
<a href="FileServlet?fileName=C:\fileuploaded\image1.jpg" title="C:\fileuploaded\image1.jpg">Click Here to download Image1 JPEG File</a>
<c:forEach var="fileName" items="${sessionScope.fileNames}">
   <a href="FileServlet?fileName=<c:uri value="${fileName}"/>" title="<c:out value="${fileName}"/>">Click Here to download</a>
</c:forEach>
-------------------------------------------------------------------------FileServlet.java
===========
package com;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLConnection
public class FileServlet extends HttpServlet{
  private void processAction(HttpServletRequest request,HttpServletResponse response) throws Exception{
       // getting fileName which user is requesting for
       String fileName = request.getParameter("fileName").replace('\\','/');
       boolean exists = new File(fileName).exists();
       // Checking whether the file Exists or not      
       if(exists){
        FileInputStream input = null;
        BufferedOutputStream output = null; 
        int contentLength = 0;
        try{
            // Getting the Mime-Type
            String contentType = URLConnection.guessContentTypeFromName(fileName); 
            if(contentType == null)        
               contentType = "application/octet-stream";
            input = new FileInputStream(fileName);
            contentLength = input.available();
            // Enables us to specify of what kind of content we are trying to download.
            response.setContentType(contentType);
            // Specifes How much amountof data we straming & trying to download
            response.setContentLength(contentLength);
            // Adding Content Disposition header so that it cud enable us to get OPEN/SAVE  after clicking on the link 
            response.setHeader("Content-Disposition","attachment;filename="+fileName+"\");
            // Initializing File Streaming Response via a Servlet
            output = new BufferedOutputStream(response.getOutputStream());
            // Placing each byte on to the stream after reading it from the file
            while ( contentLength-- > 0 ) {
               output.write(input.read());
             // Flushing the stream.         
             output.flush();
          }catch(IOException e) {
                 System.err.println("Exception Occured:"+e.getMessage());
             System.err.println("Exception Localized Message:"+e.getLocalizedMessage());
          } finally {
               // Closing the INPUT stream 
               if (input != null) {
                   try {
                      input.close();
                  } catch (IOException ie) {
                      System.err.println("Exception Occured:"+e.getMessage());
                         System.err.println("Exception Localized Message:"+e.getLocalizedMessage());                      
               // Closing the OUTPUT stream 
               if (output != null) {
                   try {
                      output.close();
                  } catch (IOException ie) {
                      System.err.println("Exception Occured:"+e.getMessage());
                         System.err.println("Exception Localized Message:"+e.getLocalizedMessage());                      
       }else{
         response.sendRedirect("/errorPage.html");
  public void doPost(HttpServletRequest request,HttpServletResponse response) throws Exception{       
        processAction(request,response); 
  public void doGet(HttpServletRequest request,HttpServletResponse response) throws Exception{
        processAction(request,response); 
}And if you are thinking of hiding filepath & all...
Here is a hint for you...
Try to maintain a properties file which has a key value pairs of that something like.
112345678=C:\\uploadfile\\image1.jpg
122142637=C:\\uploadfile\\image2.jpg
or create a Database table which which an autogenerated primany key with some Id and holds the complete filePath.
and in this case you would access the file something like the one below from your jsp
<a href="FileServlet?fileId=112345678" title="112345678">Click Here to download Image1 JPEG File</a>
<c:forEach var="fileId" items="${sessionScope.fileNames}">
   <a href="FileServlet?fileId=<c:uri value="${fileId}"/>" title="<c:out value="${fileId}"/>">Click Here to download</a>
</c:forEach>
-------------------------------------------------------------------------and in the fileServlet you might have to change the below part to
// getting fileName which user is requesting for
       String fileName = request.getParameter("fileName").replace('\\','/');to something like
// getting fileName which user is requesting for
       String fileId = request.getParameter("fileId");
   /*Querying the database or reading the Properties file to findout the correspoding filePath associated with the fileId something like*/
    String fileName = ResourceDelegate.getInstance().getFile("fileId").replace('\\','/');
NOTE:* The idea is similar to what my fellow poster is trying to explain you in all his posts.
Hope that might help :)
REGARDS,
RaHuL

Similar Messages

  • Make files downloadable from outside tomcat(web) context

    Hi there,
    I made an application on whicht people can upload word/pdf files.
    I put them in a dir called /opt/customer/2342/ , where 2342 is the customer id.
    The files are stored there, because I don't want people to be able to just download the files by using http://www.blahblah.com/customer/2342
    Now I want to create a servlet or jsp file that is able to make the files downloadable for specific users.
    Of course I can find the files using java.util.File. But I don't have a clue how to make them downloadable from this path. Should it be something with a FileStream... ?? And adding the mime-type?
    Can anybody give me some hints on making files downloadable from a specific dir?
    Thanks in advance.
    Jeroen van Hertum

    here is a servlet that is used to load files that are stored on the file system. The user submits the file path releative to a know file path.
    package common.servlet;
    import java.io.*;
    import java.net.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.log4j.Logger;
    public class FileResourceServlet extends HttpServlet
        // -------- Static fields ----------------------------------------------
        // Logger
        private static Logger logger = Logger.getLogger(FileResourceServlet.class.getName());
         * Root context for all JNDI lookups
        private static final String ROOT_CONTEXT = "java:comp/env";
         * JNDI lookup name of the binary path value
        private static final String BINARY_PATH_KEY = "binaryPath";
         * Default in case looking it up from the environment fails
        private static final String DEFAULT_FILE_RESOURCE_PATH = "/home/cp/bin";
        // -------- Fields -----------------------------------------------------
        private String fileResourcePath = null;
        // -------- Methods ----------------------------------------------------
         * Initializes the servlet.
        public void init(ServletConfig config) throws ServletException
            super.init(config);
            try
                //Get Norm's info
                Context initCtx = new InitialContext();
                Context envCtx = (Context)initCtx.lookup(ROOT_CONTEXT);
                fileResourcePath = (String)envCtx.lookup(BINARY_PATH_KEY);         
            catch( Exception e )
                logger.error("Error looking up file resource path, going with " +
                             "default value - " + DEFAULT_FILE_RESOURCE_PATH, e);
                this.fileResourcePath = DEFAULT_FILE_RESOURCE_PATH;
            logger.debug("File Resource Path:" + fileResourcePath );
         * Destroys the servlet.
        public void destroy()
         * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request,
                                      HttpServletResponse resp)
                                      throws ServletException, IOException
            ServletContext sc = getServletContext();
            String pathInfo = request.getPathInfo();
            logger.debug("Path Info: " + pathInfo);
            if (pathInfo!=null && !pathInfo.startsWith("/")) pathInfo = "/" + pathInfo;
            String filename = fileResourcePath + pathInfo;       
            logger.debug("Binary Filename:" + filename );
            // Get the MIME type of the image
            String mimeType = sc.getMimeType(filename);
            if (mimeType == null)
                //sc.log("Could not get MIME type of " + filename);
                logger.warn("Could not get MIME type of " + filename);
                resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                return;
            // Set content type
            resp.setContentType(mimeType);
            // Set content size
            File file = new File(filename);
            resp.setContentLength((int)file.length());
            // Open the file and output streams
            FileInputStream in = new FileInputStream(file);
            OutputStream out = resp.getOutputStream();
            // Copy the contents of the file to the output stream
            byte[] buf = new byte[2048];
            int count = 0;
            while ((count = in.read(buf)) >= 0)
                out.write(buf, 0, count);
            in.close();
            out.close();
         * Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request,
                             HttpServletResponse response)
                             throws ServletException, IOException
            processRequest(request, response);
         * Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request,
                              HttpServletResponse response)
                              throws ServletException, IOException
            processRequest(request, response);
         * Returns a short description of the servlet.
        public String getServletInfo()
            return "Short description";
    }

  • How to make File Dialog in different color

    Hi to all,
    How to make File Dialog to appear in orange color.
    Regards
    khiz_eng

    I would like to know this also.....but it appears that there is not much you can do with an AWT FileDialog (not even moving it to the center of the screen).
    sigh....
    V.V.

  • How To Make File Association Changes Permenant

    I'm having a problem with file associations reverting back every time I turn of my computer.
    I'm using Finder "change all" function to change the file association.  It works until I turn off my computer.  Once rebooted file associations return.
    It's a real hassle.  For some reason MP4 files keep getting associated with Windows media player. Everytime I try to open one, parallalels loads up windows. 
    Any advise?

    ekohanowich wrote:
    how to make file able to open on pc
    I assume you mean Windows Computer.
    in Keynote:   file > export > PowerPoint
    Each Windows machine will need  Powerpoint or PowerPoint Viewer installed.

  • How to make file able to open on pc

    how to make file able to open on pc

    ekohanowich wrote:
    how to make file able to open on pc
    I assume you mean Windows Computer.
    in Keynote:   file > export > PowerPoint
    Each Windows machine will need  Powerpoint or PowerPoint Viewer installed.

  • In the jspdynpage how to implements file download!!!!

    in the jspdynpage how to implements file download!!!!
    in the portal's view i need to implements download file like *.xls,i don't know how to do. and if servlet can be used in the portal application!
    Edited by: xuhuanjun on Apr 8, 2009 9:57 AM

    Hi,
    Check the below thread that will help you.
    How to get a file download window using URL component in HTMLB/JSPDynpage
    Raghu

  • How to make a downloadable report of application log file.

    Hi Every One,
    i am new to this ABAP environment, I have application logs in my system, i need to generate the reports based on my filter condition and i need to download them as file/report, For example;
    I need a Application Log report for:
    only Particular User
    only particular time
    only importent logs
    only errors
    like that....so on..
    Can any one give me step by step, how to make a report of application logs, i know only i can see logs use transaction CodeSLG1. I want to make report them.
    Thank you
    Regards
    Ravi

    Found answer in log itself

  • How to make automatic download for mp3 files [80 gb of mp3 files stored in GoDaddy]

    I'm building this site --> Matthew
    I want my visitors to download the mp3 simply by clicking the "down" blue icon. But here's the challenge, I can't do "Link to File" cause I have a lot mp3 files [80 gb total]. I believe Muse can't carry those in one file. I already stored those in my GoDaddy account.
    Right click "Save Links as.." is not an option.
    Hopefully there's another way to do it.
    Thanks!
    Debs

    Hello,
    Please look at the link below:
    Force a File to Download Instead of Showing Up in the Browser « Tips and Tricks HQ Forum
    There is a section with heading that has 3 advises under heading "How to force a file download for all my files". you can use option 1 or 3.
    Regards
    Vivek

  • Filename on file download from jsp

     

    This may help:
              ----- Original Message -----
              From: "Erik Lindquist" <[email protected]>
              Newsgroups: weblogic.developer.interest.jsp
              Sent: Wednesday, June 28, 2000 6:20 PM
              Subject: How to dynamically display images in JSPs
              > This took a little while to figure out so I thought I'd share. After
              > doing some research I was led to the following approach on how to load
              > images from an Oracle database into a JSP:
              >
              > The "main" JSP:
              >
              > <HTML>
              > <head>
              > <title>Image Test</title>
              > </head>
              > <body>
              > <center>
              > hello
              > <P>
              > <img border=0 src="getImage.jsp?filename=2cents.GIF">
              > <P>
              > <img border=0 src="getImage.jsp?filename=dollar.gif">
              > <P>
              > world
              > </body>
              > </HTML>
              >
              >
              > And this is the image getter:
              >
              > <% try {
              > response.setContentType("image/gif");
              > String filename = (String) request.getParameter("filename");
              > java.sql.Connection conn =
              > java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              > connect to db
              > java.sql.Statement stmt = conn.createStatement();
              > String sql = "select image from testimage where filename = '" +
              > filename + "'";
              > java.sql.ResultSet rs = stmt.executeQuery(sql);
              > if (rs.next()) {
              > byte [] image = rs.getBytes(1);
              > java.io.OutputStream os = response.getOutputStream();
              > os.write(image);
              > os.flush();
              > os.close();
              > }
              > conn.close();
              > }
              > catch (Exception x) { System.out.println(x); }
              > %>
              >
              >
              > The thing to note is that there are no <%@ page import="..." %> or <%@
              > page contentType="..." %> tags - just the single scriptlet. It
              > seems that for every "<%@" the weblogic compiler sees it puts
              > out.print("\r\n"); statements in the generated java source.(???) I
              > don't know much about how browsers work but I think that once it sees
              > flat ascii come at it it treats everything that follows as text/plain
              > which is incorrect for the binary stream that's being sent. Another
              > work around was to set out = null; but that's kind of ugly and might
              > produce server errors. The real fix is to write a bean to handle images
              > which I'll work on next (does anybody have any hints on how to do
              > that?)
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Ramesh" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi,
              >
              > Even I could download the files with this technique, I couldn't open the
              file downloaded. It seems the file is getting currepted during tranfer.. Can
              u help me in this regard please?
              >
              > Thank u
              > Ramesh
              >
              > [email protected] (Anders B. Jensen) wrote:
              > >In an Web-application written in Java Server Pages it should be possible
              > >for the user to download data from the web-server. The data will never
              > >exist as a file on the web-server, only in the PrintWriter object, out.
              > >To force the Internet Explorer (IE) to show the download dialog window
              > >the Contenttype of the HTTP-header have been set to "html/transfer". The
              > >question is:
              > >
              > >Is it possible to set the filename appearing in the download dialog
              > >appearing on the client?
              > >
              > >
              > >Below is a listing of the source-code:
              > >
              > ><%@ page extends="com.beasys.portal.admin.PortalJspBase"%>
              > ><jsp:useBean id="download" scope="session" class="dk.lec.DownloadData" />
              > >
              > ><%
              > > String tmpstr;
              > > response.setContentType("html/transfer");
              > > out.clear();
              > > tmpstr=download.getStrbuffer().toString();
              > > out.println(tmpstr.trim());
              > >%>
              > >
              > >
              > >Anders B. Jensen
              > >Consultant, Research & Development
              > >LEC AS
              > >
              > >Remove the SPAMLESS to mail me.
              >
              

  • File download with JSP

    I have found some code within this forum that I have been attempting to use to allow customers to download text files to their PC's. The code below is what I have come up with from my understandings on exactly how it should work, but it just will not work ...
    Am I correct in assuming that the file that I want to make available for download is specified within the File f = new File(path+filename); section???
    I have made the path variable refer directly to the file system (/disk2/invoice/) as well as via http (http://domain.com/invoice/) but it will not work !!!
    It returns the save/open dialog but as soon as I select an option it returns a windows error prompt as follows:
    Internet Explorer cannot download ...p?filename=123414_76453_437 from www.domain.com.
    Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
    Can someone please tell me, where am I supposed to reference the file to be downloaded and how am I to reference it ???
    <%
    // get the file name from the calling page
    String filename = request.getParameter("filename");
    //get the file path to the file I want to make available via download
    String path = getServletContext().getInitParameter("invoicePath");
    response.setContentType("text/plain");
    response.setHeader("Content-Disposition","attachment; filename=\""+filename+"\";");
    int iRead;
    FileInputStream stream = null;
    try {
         File f = new File(path+filename);
         stream = new FileInputStream(f);
         while ((iRead = stream.read()) != -1) {
              out.write(iRead);
         out.flush();
    finally {
         if (stream != null) {
              stream.close();
    %>
    <%@ page import="java.io.*,javax.servlet.*,java.util.* " contentType="text/html" %>
    <html>
    finally we have success ...     
    </html>

    For those of you who are still having issues that have been unresolved trying to download a file from a webserver to a client, I have finally figured out how to do so ...
    The following code now works for me on Solaris running Tomcat 3.1 and on W2K running JRun 3.2 ...
    Issue 1: I specified a contentType=text/html in the page specification ... This must be removed ...
    <%@ page ... contentType=text/html%>
    Issue 2: The new File() reference must be a direct path to the file on the operating system. This does not work if it is referenced with a http path.
    Other than that, I have included the code that I use to make files available for download on our webserver.
    <%@ page import="java.io.*,javax.servlet.*,java.util.* "%>
    <%
    // get the file name
    String filename = request.getParameter("filename");
    //get the file path
    String path = getServletContext().getInitParameter("invoicePath");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition","attachment; filename=\""+filename+"\";");
    int iRead;
    FileInputStream stream = null;
    try {
         File f = new File("/disk2/wwwhome/psmerged/invoice/" + filename);
         stream = new FileInputStream(f);
         while ((iRead = stream.read()) != -1) {
              out.write(iRead);
         out.flush();
    finally {
         if (stream != null) {
              stream.close();
    %>

  • How to make a download page?

    Hi!
    I need to make a downloadable page out of a stream (or byte array - it doesn't matter) with a content of any type (e.g. a csv file or a binary file).
    I would like to make a link on a page which whould trigger an event. In the event handler I would prepare the needed data (generate, etc.) and let the client download it as a binary file (so that browser whould display a download page with options to open the file or save it).
    The problem is that I can't find out how to do that?
    Are there any how-tos or examples?
    Thanks!

    Well, a problem arised again when we moved our web application to the https protocol. DownloadPageRenderer didn't work at all with Internet Explorer browser, however other browser worked well and downloaded our file.
    I've made a separate servlet for simply returning a file from HttpSession in a doGet method, this is done by the following code:
    public class FileDownloadServlet extends HttpServlet  {
       * Process the HTTP doGet request.
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        System.out.println("FileDownloadServlet.doGet() call in progress . . .");
        response.setContentType(contentType);
        response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
        OutputStream os = response.getOutputStream();
        // save our data to the OutputStream...
        os.close();     
    }This code works well with Internet Explorer in our test server, Oracle9iAS/9.0.2. However this doesn't work with Internet Explorer on the client's server, Oracle9iAS/9.0.2.3.0.
    In our server (where it works), I get the following HTTP headers in IE (with ieHttpHeaders IE plugin):
    HTTP/1.1 200 OK
    Date: Tue, 31 Aug 2004 07:36:49 GMT
    Server: Oracle9iAS/9.0.2 Oracle HTTP Server
    Set-Cookie: JSESSIONID=<skipped>; Path=/
    Cache-Control: private
    Content-Disposition: attachment;filename="HTD Proov.htm"
    Keep-Alive: timeout=15, max=98
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=UTF-8On client's server (where it doesn't work):
    HTTP/1.1 200 OK
    Date: Tue, 31 Aug 2004 07:36:03 GMT
    Server: Oracle9iAS/9.0.2.3.0 Oracle HTTP Server
    Pragma: no-cache
    Cache-Control: no-store
    Surrogate-Control: no-store
    Expires: Sat, 11 Jul 1970 17:55:19 PST
    Set-Cookie: JSESSIONID=<skipped>; Path=/komm
    Cache-Control: private
    Content-Disposition: attachment;filename="proov.htm"
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=UTF-8Any ideas about how to make IE work with our application are welcomed. Can this be because of a wrong server configuration? Can any HTTP headers of the second response cause such behaviour in IE?
    Thanks,
    Alexey.

  • How to make excel export in jsp

    Hi All,
    I have a jsp page to display a table. I want to add a "excel download" button
    in this page, once user click this button, it will invoke the microsoft excel
    and all table content will appear in the excel spreadsheet.
    I tried to set the content: <%@ page contentType="application/vnd.ms-excel"%>
    the rest code as following. However, it won't work for me. Does anyone has any
    experience in doing this?
    <%@ page contentType="application/vnd.ms-excel"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <netui:html>
    <head>
    <title>
    Web Application Page
    </title>
    </head>
    <body>
    <table border="1">
    <tr style="background-color:#3366ff;font-family:arial;">
    <td>Structure</td>
    <td>Compound</td>
    <% // Get the Items from the request stream
                   Vector mr_names = (Vector) request.getAttribute("method_result_names");
    for (int f=0;f<mr_names.size();f++) {
    out.println("<td>" + mr_names.get(f) + "</td> ");
    Vector mrs = (Vector) request.getAttribute("method_results");
    for (int g=0; g<mrs.size(); g++)
    out.println("</tr><tr>");
    Vector row1 = (Vector)mrs.get(g);
    for (int f=0;f<mr_names.size()+1;f++) {
    String s = (String)row1.get(f);
    if (f==0) {
    %>
    <td><embed src="structure.jsp?Sample_code=<%=s%>" width="120" height="100"></embed></td>
    <%
    out.println("<td>" + s + "</td> ");
    out.println("</tr>");
    %>
    </table>
    </body>
    </netui:html>
    Thanks!
    Zhenhao

    I am trying to do the same thing. I also cant get it to work. I am
    thinking it may have something to do with the concept of ScopedResponse, but
    I am not sure. There is very little documentation and more importantly
    examples of how to make sense of the getOuterResponse() method. Dev2Dev and
    Google are of no help.
    Anyone care to explain this to us?
    Michael.
    "Zhenhao Qi" <[email protected]> wrote in message
    news:3fd4f634$[email protected]..
    >
    Hi All,
    I have a jsp page to display a table. I want to add a "excel download"button
    in this page, once user click this button, it will invoke the microsoftexcel
    and all table content will appear in the excel spreadsheet.
    I tried to set the content: <%@ pagecontentType="application/vnd.ms-excel"%>
    the rest code as following. However, it won't work for me. Does anyone hasany
    experience in doing this?
    <%@ page contentType="application/vnd.ms-excel"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <netui:html>
    <head>
    <title>
    Web Application Page
    </title>
    </head>
    <body>
    <table border="1">
    <tr style="background-color:#3366ff;font-family:arial;">
    <td>Structure</td>
    <td>Compound</td>
    <% // Get the Items from the request stream
    Vector mr_names = (Vector) request.getAttribute("method_result_names");
    for (int f=0;f<mr_names.size();f++) {
    out.println("<td>" + mr_names.get(f) + "</td> ");
    Vector mrs = (Vector)request.getAttribute("method_results");
    for (int g=0; g<mrs.size(); g++)
    out.println("</tr><tr>");
    Vector row1 = (Vector)mrs.get(g);
    for (int f=0;f<mr_names.size()+1;f++) {
    String s = (String)row1.get(f);
    if (f==0) {
    %>
    <td><embed src="structure.jsp?Sample_code=<%=s%>"width="120" height="100"></embed></td>
    >
    <%
    out.println("<td>" + s + "</td> ");
    out.println("</tr>");
    %>
    </table>
    </body>
    </netui:html>
    Thanks!
    Zhenhao

  • How to make a download from portlet?

    Hi there!
    How to do make a download in portlet. Standart methods don't work becouse Portal inserts it's headers first the file gets to a user.
    What can I do?
    Thanks in advance!

    Check out the Portal Development Kit (PDK) available at http://portalstudio.oracle.com/
    Hope this helps,
    Rob

  • PDF files download as JSP

    I just upgraded to Leopard 10.5.6 this weekend from Tiger 10.4.11 then upgraded to 10.5.8. All went well except for a small glitch in Mail which I got fixed with the help of this forum. My newest problem is this morning I went online to my bank to download our monthly statement which always is in PDF format. The file downloaded fine, except the file title says it's a PDF, but the extension is .jsp. I contacted the bank and they have changed nothing so I am wondering is there a setting I need to change somewhere that would affect the download? At present I haven't found an application that will open .jsp files, but first I want to get them back to PDF format. Any suggestions will be appreciated.

    Title Man wrote:
    I just upgraded to Leopard 10.5.6 this weekend from Tiger 10.4.11 then upgraded to 10.5.8. All went well except for a small glitch in Mail which I got fixed with the help of this forum. My newest problem is this morning I went online to my bank to download our monthly statement which always is in PDF format. The file downloaded fine, except the file title says it's a PDF, but the extension is .jsp. I contacted the bank and they have changed nothing so I am wondering is there a setting I need to change somewhere that would affect the download? At present I haven't found an application that will open .jsp files, but first I want to get them back to PDF format.
    Have you tried renaming the file so that its extension is ".pdf"? I believe I regularly download PDF files that have "jsp" in the file name, but renaming them corrects the problem.

  • How to control File Download window

    I am using javax.servlet.ServletOutputStream for downloading the files. I am reading the InputStream from data base and writing into the ServletOutputStream object. I set the HttpServletResponse content type to "application/octet-stream".
    When I tried to download the file, the browser(IE) displaying the File Download window that consist of Name, Type and From details. How can I set the values for Name, Type and From fields. Also is it possible to customize the buttons like Open, Save, Cancel on this File Download window.
    Any help will be heighly approciated.
    Regards
    Venkat

    this is simple code for downloading , if you don't get desired results then specify ur problem in detail
    package p1;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Download extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    res.setContentType("text/html");
    ServletContext ctx=getServletContext();
    InputStream is=ctx.getResourceAsStream("/xyz.jar");
    int read=0;
    byte []bytes=new byte[1024];
    OutputStream os=res.getOutputStream();
    while((read=is.read(bytes))!=-1)
    os.write(bytes,0,read);
    os.flush();
    os.close();
    }

Maybe you are looking for

  • No audio when connecting iMac to LED TV

    I connected my iMac (using a mini display to DVI adapter) to my LED TV (using an HDMI to DVI Digital Video Cable), the picture appears but the only sound there is is that coming out of the iMac. Under system preferences their is only the internal spe

  • Workbook won't open after import into test environment - Function Related

    Hi Experts, We have a disco report that uses a custom database function. The function has been registered and is valid in the development environment and the report works fine. We have exported the business area, report and relevant functions from th

  • How do I clear the downloads folder?

    How do I clear the downloads folder?  I swear there used to be an option for this when I right clicked on the downloads folder that is on my bottom bar but I don't see one now.  This is making me crazy. Also, when I click on the bottom bar Downloads

  • Loading picture problem

    I'm having problem with loading picture in applet window. Here is the example CODE: * <applet code="SimpleImageLoad" width=248 height=146> * <param name="img" value="seattle.jpg"> * </applet> import java.awt.*; import java.applet.*; public class Simp

  • Trying to DL PS CC  But say my Operating Systen no longer supported! Running Windows 7  HELP

    Anybody having issued with Download PS CC.  It says my operating system no longer Supported.  Here is what I'm running; Win 7 Service Pack 2 Processor: Intel i7 930 @ 2.80 GHz Ran 13 GB 64 Bit system