Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need Hellp!! problem with org.apache.struts.actions.DownloadAction.copy

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need Hellp!! problem with org.apache.struts.actions.DownloadAction.copy

    Hello All,

    I am facing a problem in my application when it is being deployed on server where we are using tomcat, application runs fine on localhost. I am using struts for developing the application.

    In one part of the application I am extending org.apache.struts.actions.DownloadAction class to download a file which is present on the server.

    but it throws this exception


    exception

    javax.servlet.ServletException
    org.apache.struts.action.RequestProcessor.processE xception(RequestProcessor.java:523)
    org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
    org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
    org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1194)
    org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:729)


    root cause

    java.lang.NullPointerException
    org.apache.struts.actions.DownloadAction.copy(Down loadAction.java:139)
    org.apache.struts.actions.DownloadAction.execute(D ownloadAction.java:112)
    org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:419)
    org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:224)
    org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1194)
    org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:729)



    my action class goes like this...

    import java.io.File;
     
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.actions.DownloadAction;
    import org.apache.struts.actions.DownloadAction.ResourceStreamInfo;
    import org.apache.struts.actions.DownloadAction.StreamInfo;
     
    import javax.servlet.http.HttpSession;
    import forms.UploadFileForm;
     
    public class DownloadMagazineAction extends DownloadAction
    {
    protected StreamInfo getStreamInfo(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
    {
    String filepath = null;
    String foldername = null;
     
    HttpSession session = request.getSession(true);
     
    UploadFileForm uploadform = (UploadFileForm) form;
     
     
    System.out.println("sesssion month and year in download action is " + session.getAttribute("month")+ session.getAttribute("year"));
    foldername = (String)session.getAttribute("month") + session.getAttribute("year");
    System.out.println("folder name from session : " + foldername);
     
    String fileName = request.getParameter("filename");
    System.out.println("filename : " + fileName);
     
    filepath = "Magazine_" + foldername + "/" + fileName;
    System.out.println("Filepath : " + filepath);
     
    File file = new File(filepath);
     
    String name = file.getName();
     
     
    String contentType = "application/octet-stream";
    response.setHeader("Content-disposition", "attachment; filename=" + name);
    response.setHeader("Pragma", "no-cache"); 
     
    ServletContext application = servlet.getServletContext();
    System.out.println("application : " + application);
     
     
    return new ResourceStreamInfo(contentType, application, filepath);
    }
    }

    I was taking the month and year from the form object but to see if the problem is because of the form I changed the same to session and tried to get the data from session variable. But still it is not working.

    I dnt know from where this DownloadAction.copy is generated and why is the application giving error after deployment and not at server

    can somebody please help me out with this problem... I am tryig to get rid of this from last so many days but have not got any success

    Questions or comments? Feel free to post them here. No login or id required.


  2. #2
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: Need Hellp!! problem with org.apache.struts.actions.DownloadAction.copy

    Is there any body who can help me out??

Similar Threads

  1. program a button that copy whatever in a JTextArea
    By voltaire in forum AWT / Java Swing
    Replies: 5
    Last Post: May 17th, 2010, 12:43 AM
  2. Problem running Apache tomcat 6.0 using i.p. address
    By nakul in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: April 8th, 2010, 07:58 AM
  3. org.apache.derby does not exist?
    By disclaimer in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 30th, 2010, 04:58 PM
  4. do actions in ComboBox
    By java_cs in forum AWT / Java Swing
    Replies: 2
    Last Post: October 1st, 2009, 10:53 AM
  5. apache-jboss
    By supriya ramjee in forum Web Frameworks
    Replies: 0
    Last Post: August 12th, 2009, 05:37 AM

Tags for this Thread