Download a file using servlet

Hi,
i need to download a file using servlet (jsp frontend) and if the download is successful, then a success message shud be displayed on the jsp.
i have tried it using MultipartResonse object and have been able to download the file. The problem is displaying the message on a jsp after download. After download if i use RequestDispatcher object to forward control to another jsp, it doesnt happen.
Can anyone help me with this?

Hi,
You can check :-
http://www.servletsuite.com/servlets/download.htm
Best of luck.
R S

Similar Messages

  • How to download a file using servlet

    I have a problem about downloading a file using a servlet.
    Anybody can help me?
    Thanks

    I am assuming that you want to write a servlet that, when invoked by a user (for instance, through a URL link), will download a file using the "save as" dialog (on Windows, for example) in the user's browser.
    In such a case, all you need to do is get the OutputStream from the response object, set the proper MIME type header, and write the file. Here is an (untested, not even compiled) skeleton.
    public class MyServlet extends HttpServlet {
    protected void doGet (HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    ServletOutputStream out = resp.getOutputStream ();
    resp.setContentType ("application/x-foobar");
    while (/* whatever */) {
    In this loop, you generate your "file's" data.
    You can compute it on the fly, pull it from a database,
    read it from a "real" file, or any other means you can dream up.
    The sample line below just writes some of the data (for example,
    a byte array) to the user's browser via the output stream out.
    out.write (data);
    out.flush ();
    Go to http://java.sun.com/j2ee/sdk_1.3/techdocs/api/index.html
    for the JavaDoc on the classes used.
    Cheers!
    Jerry Oberle

  • Download local file using Servlet and JSP

    Hello,
    I will like to use a browser to download file on local system using serlvet and Jsp technology. Does anyone have any idea how to do it?
    Any comment will be appreciate.
    Thanks

    Well you can just put the file in a folder that is accessible to the web server. Then have a link point to that file. That will cause the web browser to download the file.
    hattan

  • Can any one help me to download a file using struts2

    can any send me a sample program to download a file using struts2
    regards
    saradhi

    i cannot find it in google please help me by sending a link or a code
    thanking u
    regards saradhi
    while i am executing this code i am getting error
    javax.servlet.ServletException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
         org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
         org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
         org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:189)
         org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
         com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
         com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
         com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
         org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
         com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
         com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
         com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
         com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
         com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
         com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
         org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
         org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
         org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17
    and my code is as follows
    download action.java
    package com.mss.mirage;
    import java.io.InputStream;
    import org.apache.struts2.ServletActionContext;
    import com.opensymphony.xwork2.ActionInvocation;
    import com.opensymphony.xwork2.Action;
    * Demonstrates file resource download.
    * Set filePath to the local file resource to download,
    * relative to the application root ("/images/struts.gif").
    public class FileDownloadAction implements Action {
    private String inputPath;
    private String contentType;
    private String inputName;
    private String contentDisposition;
    private String fileId;
    private int bufferSize;
    public void setInputPath(String value) {
    inputPath = value;
    public InputStream getInputStream() throws Exception {
    return ServletActionContext.getServletContext().getResourceAsStream(getInputPath());
    public String execute() throws Exception {
    return SUCCESS;
    public String getInputPath() {
    return inputPath;
    public String getContentType() {
    return contentType;
    public void setContentType(String contentType) {
    this.contentType = contentType;
    public String getInputName() {
    return inputName;
    public void setInputName(String inputName) {
    this.inputName = inputName;
    public String getContentDisposition() {
    return contentDisposition;
    public void setContentDisposition(String contentDisposition) {
    this.contentDisposition = contentDisposition;
    public String getFileId() {
    return fileId;
    public void setFileId(String fileId) {
    this.fileId = fileId;
    public int getBufferSize() {
    return bufferSize;
    public void setBufferSize(int bufferSize) {
    this.bufferSize = bufferSize;
    download.jsp
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head>
    <title>Showcase - Fileupload</title>
    </head>
    <body>
    <h1>File Download Example</h1>
    <ul>
    <li>
    <s:url id="url" action="download2"/><s:a href="%{url}">Download ZIP file.</s:a>
    The browser should prompt for a location to save the ZIP file.
    </li>
    </ul>
    </body>
    </html>
    struts.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <package name="download" extends="struts-default" namespace="/download">
    <default-action-ref name="download"/>
    <action name="download2" class="com.mss.mirage.FileDownloadAction">
    <param name="inputPath">"c:\images\struts.zip"</param>
    <result name="success" type="stream">
    <param name="contentType">application/zip</param>
    <param name="inputName">inputStream</param>
    <param name="contentDisposition">filename="c:\images\struts.zip"</param>
    <param name="bufferSize">4096</param>
    </result>
    </action>
    </package>
    </struts>

  • Can u please send me a sample code to upload and download a file using java

    Hi,
    Please can u send me a sample code to upload a file and to download the same file from a remote server using a java servlets. The file should be read byte by byte.
    Message was edited by:
    user461713

    Hi, Thank u.
    Sorry, I forgot to attach a code. Here it is.
    Actually i need to upload a file to a remote server and download it from a server to my machine. I'm trying it using servlets and using tomcat5.0 as a servlet container. Here i'm sening a code used to upload a file. Let me know whether it works. Only few lines are here.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.lang.Object;
    import java.util.*;
    import java.lang.String;
    import com.oreilly.servlet.MultipartRequest;
    public class FileUpload extends HttpServlet{
         public void doPost(HttpServletRequest req, HttpServletResponse res)throws
         ServletException, IOException{
         MultipartRequest multi=new MultipartRequest(req);     
         String file="file1";
         byte[] b=file.getBytes();
         InputStream in=null;
         BufferedInputStream bis=null;
         FileWriter fw=null;
    try{
         in=multi.getInputStream("file1");
    bis=new BufferedInputStream(in);
         File output=new File("/fileuploadtest");
         fw=new FileWriter(output);
              int i;
              i=bis.read();
              while (i != -1) {
    fw.write(i);
    i = bis.read();
         catch(IOException e){
              System.out.println("Exception=" +e);
    finally{
         try{
              if(in!=null)
              in.close();
              if(bis!=null)               
              bis.close();
              if(fw!=null)
              fw.close();
         catch(Exception e){
              System.out.println(e);
    This code is giving error as: cannot resolve symbol: class MultipartRequest
    Why is this happening?
    Pls let me know whether this code works or no and also i have written form.html.
    Can u pls tel me whether there are ways in which i can write a code to upload a file using servlets without using third party packages. Pls help.
    Also how should be the servlet mapping for this code.?
    Regards
    Message was edited by:
    user461713

  • How to parse the xml file using servlet

    My scenario is like this:
    <b>FILE-->XI-->J2EE Application</b>
    XI sends the xml file to j2ee application. My servlet receives the file in HTTPRequest string. 
    How to parse that file using servlets.I should get the xml file as it is and should be displayed in the browser.
    Can anyone please help me with code, its urgent.
    Please help me!

    Download this java code
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/work/Echo02.java
    in your servlet code you can write
    public void doPost(req,resp){
    DefaultHandler handler = new Echo02();
    handler.parse(req.getInputStream());
    Offcourse you will need to modify the code of Echo02 class a bit to suit your requirement which would finally retrun you a string and you can then write it using
    respose.getWriter().write(responseString);

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • How do I download PDF files using Safari.  All I get is a black screen.

    How do I download PDF files using Safari.  All I get is a black screen.

    Back up all data.
    Quit Safari. In the Finder, select Go ▹ Go to Folder... from the menu bar, or press the key combination shift-command-G. Copy the line of text below into the box that opens, and press return:
    /Library/Internet Plug-ins
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then launch Safari and test.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • To download a file using Ftp.

    I am making a web application using struts framework . now on one jsp page i'll have to give the list of files on the ftp server and link to download those files using ftp from the ftp server.
    I have made functions using jakarta commons.net library by which i m able to show the list of files on jsp page but i m not able to give download link bcos using the function the file is downloaded on the server on which my application is running . and not from which i am accessing through the browser.........
    If any one have any idea pls let me know...........?
    Regards,
    Neeraj.

    If it's anonymouse FTP to download from the server, just make the page have a link to the FTP site..
    some file

  • How to read a file using servlet

    hi ,
    i've to read a file using servlet ,
    should read the file using servlet and display it in JSP,Could anybody get me how can i do it .
    Shiva

    To do that you need to get the response output stream and write yur file contents to that.
    response.setContentType(mimeType); //Set the mime type for the response
    ServletOutputStream sos = resp.getOutputStream();
    sos.write(bytes from your file input stream);
    sos.close();

  • Download a file using GetRight

    How is it possibe to download a file using a downloader like getright? I am trying to get
    oracle-xe-universal_10.2.0.1-1.0_i386.deb
    but if I transfer it to Getright it fails to login, although I ve done it using the browser.

    Well, normally it does. It's only at oracle.com that it doesn't work, and I wonder why. I tried putting directly the uid and the passwd but it didn't work either.

  • Problem downloading .doc, .xls file using servlet

    i have a servlet which downloads the files to client(browser). It works file for .txt file but .doc, .xls files are opend but they contain garbage.
    plz letr me know if u know problem!!!!!
    -amit

    Probably because you output them using the Writer you got from getWriter instead of using the OutputStream you can get from getOutputStream.

  • Null pointer exception while downloading a file using a servlet

              Hi all
              I am getting the following error when downloading a file
              by invoking a servlet ...
              The following is the offending piece of code which has the
              problem ..
              protected void doGet( HttpServletRequest req,
                   HttpServletResponse resp ) throws ServletException,IOException
              resp.setContentLength ( length );
              OutputStream out = resp.getOutputStream();
              FileInputStream is = new FileInputStream(file);
              WriteToStream(is, out);
              out.flush(); // Error happens here
              out.close();
              java.lang.NullPointerException
              at weblogic.servlet.internal.ChunkOutput.clearBuffer(ChunkOutput.java:231)
              at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:251)
              at weblogic.servlet.internal.ChunkOutputWrapper.flush(ChunkOutputWrapper.java:152)
              at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java:119)
              at com.epeople.servlet.FileDownloadServlet.doFileRequest(FileDownloadServlet.java:127)
              at com.epeople.servlet.FileDownloadServlet.doGet(FileDownloadServlet.java:75)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:24
              56)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2047)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              Any help will be greatly appreciated.
              thanks,
              sri kumar
              

              Hi all
              I am getting the following error when downloading a file
              by invoking a servlet ...
              The following is the offending piece of code which has the
              problem ..
              protected void doGet( HttpServletRequest req,
                   HttpServletResponse resp ) throws ServletException,IOException
              resp.setContentLength ( length );
              OutputStream out = resp.getOutputStream();
              FileInputStream is = new FileInputStream(file);
              WriteToStream(is, out);
              out.flush(); // Error happens here
              out.close();
              java.lang.NullPointerException
              at weblogic.servlet.internal.ChunkOutput.clearBuffer(ChunkOutput.java:231)
              at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:251)
              at weblogic.servlet.internal.ChunkOutputWrapper.flush(ChunkOutputWrapper.java:152)
              at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java:119)
              at com.epeople.servlet.FileDownloadServlet.doFileRequest(FileDownloadServlet.java:127)
              at com.epeople.servlet.FileDownloadServlet.doGet(FileDownloadServlet.java:75)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
              at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:24
              56)
              at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2047)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              Any help will be greatly appreciated.
              thanks,
              sri kumar
              

  • Problem in downloading file using servlet

    Hello,
    I wnat to send a file throung servlet to my desktop program. when i call this servlet through internet explore it is working fine but when i call this in my desktop program then desktop program get nothing. my desktop program does not get anything. please help me. here is my both code servlet and desktop program.
    public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              response.setContentType("text/html");
         //     PrintWriter out = response.getWriter();
              File filename = new File("");
    //          Set the headers.
              response.setContentType("application/x-download");
              response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    //          Send the file.
              OutputStream out = res.getOutputStream( );
              returnFile(filename, out); // Shown earlier in the chapter
              String filePath = getServletContext().getRealPath("/");
              response.setContentType("application/x-download");
              response.setHeader("Content-Disposition", "attachment; filename="+"amit.doc");
         //     File tosave = new File(getServletContext().getRealPath("), cfile.getName());" +
              try{
              File uFile= new File(filePath);
              int fSize=(int)uFile.length();
              FileInputStream fis = new FileInputStream(uFile);
              PrintWriter pw = response.getWriter();
              int c=-1;
    //          Loop to read and write bytes.
    //          pw.print("Test");
              while ((c = fis.read()) != -1){
              pw.print((char)c);
    //          Close output and input resources.
              fis.close();
              pw.flush();
              pw=null;
              }catch(Exception e){
    public class AdDesktopClient {
         * @param args
         public static void main(String[] args) {
              try{ 
              URL url = new URL("http://localhost:8080/WebRoot1/servlet/Download");
              //URLEncoder.encode(xmlString);
              URLConnection connection = url.openConnection();
              HttpURLConnection con = (HttpURLConnection)connection;
              con.setDoInput(true);
              con.setDoOutput(true);
              con.setUseCaches(true);
              con.setRequestMethod("GET");
              // PrintWriter out = new PrintWriter(con.getOutputStream());
              BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
              String inputLine;
              int len = con.getContentLength();
              InputStream inn = con.getInputStream();
              byte[] buf = new byte[128];
              int c =0;
              System.out.print("len :"+len);
              System.out.print(inn.read());
              while( (c = inn.read())!= -1){
                   System.out.print(c);
    /*          while ((inputLine = in.readLine()) != null)
              System.out.println(inputLine);
              in.close();
              }catch(Exception e){
                   e.printStackTrace();
    Plaease help me to solve this problem. i want to send a file throuhg a servlet to my desktop program.
    Thanks in advance
    Ravi

    Give this a try:
    File strFile = new File(strFileName);
    long length = strFile.length();
    response.setContentType("application/octet-stream");
    response.setContentLength((int)length);
    response.setHeader("Content-Disposition", ("attachment; filename=" + strFileName));
    OutputStream out = response.getOutputStream();
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(strFile));
    int i = -1;
    while((i = in.read()) != -1) out.write(i);
    in.close();
    Kris

Maybe you are looking for

  • How can I scroll/page up or down in iTunes 11.1.2 music tab?

    I currently am using a MacBook Air and am attempting to sync my music via iTunes 11.1.2.  I would like to select the artist/genre that I want to sync however there seems to be no way to scroll up or down within the music tab/page.  HELP!!! Neither th

  • Software Update doesn't connect

    Hi. This has happened twice in a row now. HP Director tells me an update is available. I click on it and it spins its wheels. I just tried again manually, after first dropping my firewall, to no avail. I'm running the 7410 all in one printer, full so

  • SMB shared folder size limited 10gb but I need more!

    Hey. I was just wondering this. Started to build SMB share for windows users, but all the shared folders I make are limited to 10gb size. Cant find a way to make ithem larger. There is like 1,8Tb of space on that HD so I don't really know why is it l

  • How do I save individual edited MTS files in CS6

    how do I save individual edited MTS files in CS6

  • How to make a color effect

    hey, how can I make in adobe premiere pro this color effect? (looks like x-ray) thank you!!